Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Between the recent "Why does 'kill -9 0' end my console session" and "How to get a kernel panic" questions, I got a bur under my saddle and tried kill -9 1 on a mostly up-to-date Arch linux laptop. I did it as user ID "root".

I fully expected some kind of crash or panic or shutdown, but nothing happened. I did kill -9 1 again, to no effect.

Arch linux machines run systemd these days, so: how does systemd survive a kill -9? I expect there's special case code in the Linux 3.7 kernel, but maybe some other reason exists that I haven't thought of.

What about other things that run with PID 1? Slackware still uses init I believe, but I'm scared to try it on my production Slackware server. DD-WRT on my wireless router runs /sbin/init of some sort.

share|improve this question
add comment

1 Answer

up vote 26 down vote accepted

From man 2 kill:

The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.

That is, it is possible for init to do whatever it likes upon receiving SIGKILL (including exiting), but systemd's init does not install any signal handler for it, so nothing happens.

share|improve this answer
2  
Thanks for noting that. Is this Linux specific? I seem to remember crashing a SunOS workstation back in the early 90s by killing init by mistake. Or not. I was a lot more reckless in my youth. –  Bruce Ediger Mar 3 '13 at 17:04
1  
@BruceEdiger, I too seem to remember being able to kill -9 init and induce a kernel panic. Sounds like it changed at some point. –  psusi Mar 4 '13 at 2:31
1  
@BruceEdiger - I tried it for an AIX server and an HP-UX one. Both returned an error message: kill: 1: 0403-068 The signal is invalid for this process OR kill: 1: The specified process does not exist. The man page specifically mentioned that this will return an error. I am told by a number of people that this could be done previously - but no one has succeeded in the past 10+ years. –  DarkHeart Mar 4 '13 at 6:58
1  
@BruceEdiger It seems from some searching that this is a recent (at least, in terms of Unix lifespan) development. Unfortunately I wasn't alive in the early 90's, so when it happened is out of my scope of knowledge. It would be interesting to find out, though, as it seems that almost all modern Unices have changed to default to this behaviour. –  Chris Down Mar 4 '13 at 8:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.