[systemd-devel] [PATCH] [Fix] Do not handle SIGKILL since we can not

Yang Chengwei chengwei.yang at intel.com
Mon May 20 16:47:15 PDT 2013


On Mon, May 20, 2013 at 10:37:36AM -0700, Kok, Auke-jan H wrote:
> On Mon, May 20, 2013 at 12:22 AM, Chengwei Yang <chengwei.yang at intel.com> wrote:
> > This is a minor fix because it's not a major issue, this fix just avoid
> > to get EINVAL error from sigaction(2).
> >
> > There are two signals can not handled at user space, SIGKILL and
> > SIGSTOP even we're PID 1, trying to handle these two signals will get
> > EINVAL error.
> >
> > There are two kinds of systemd instance, running as system manager or
> > user session manager, apparently, the latter is a general user space
> > process which can not handle SIGKILL. The special pid 1 also can not
> > do that refer to kernel/signal.c:do_sigaction().
> >
> > However, pid 1 is unkillable because the kernel did attach
> > SIGNAL_UNKILLABLE to it at system boot up, refer to
> > init/main.c:start_kernel()
> >     --> rest_init()
> >         --> kernel_thread()
> >             --> kernel_init()
> >                 --> init_post()
> >                     current->signal->flags |= SIGNAL_UNKILLABLE
> >
> > Signed-off-by: Chengwei Yang <chengwei.yang at intel.com>
> > ---
> >  src/core/main.c  |    1 -
> >  src/shared/def.h |    2 +-
> >  2 files changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/src/core/main.c b/src/core/main.c
> > index 7fc06be..8059f6a 100644
> > --- a/src/core/main.c
> > +++ b/src/core/main.c
> > @@ -1408,7 +1408,6 @@ int main(int argc, char *argv[]) {
> >          /* Reset all signal handlers. */
> >          assert_se(reset_all_signal_handlers() == 0);
> >
> > -        /* If we are init, we can block sigkill. Yay. */
> >          ignore_signals(SIGNALS_IGNORE, -1);
> >
> >          if (parse_config_file() < 0)
> > diff --git a/src/shared/def.h b/src/shared/def.h
> > index 5ba170f..5abb544 100644
> > --- a/src/shared/def.h
> > +++ b/src/shared/def.h
> > @@ -32,4 +32,4 @@
> >  #define SYSTEMD_CGROUP_CONTROLLER "name=systemd"
> >
> >  #define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
> > -#define SIGNALS_IGNORE SIGKILL,SIGPIPE
> > +#define SIGNALS_IGNORE SIGPIPE
> 
> Ok, looks fine to me. Was there an error printed by user sessions?

Yes, even I get log from systemd system session (pid 1), see below.

sh-4.1# dmesg | grep "Invalid argument"
[    6.420409] systemd[1]: sigaction failed: 9(Invalid argument)

sh-4.1# systemd-journalctl -a --no-pager | grep ignore
May 20 15:12:20 TRATS2 systemd[2346]: ignore_signals failed: -22(Invalid argument)

sh-4.1# ps aux | grep 2346
app       2346  0.4  0.2   3676  1880 ?        Ss   15:12   0:00 /usr/lib/systemd/systemd --user

--
Thanks,
Chengwei

> 
> Auke
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130521/9839593a/attachment.pgp>


More information about the systemd-devel mailing list