Can root kill init process?

By default, no, that's not allowed. Under Linux (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.

Pid 1 (init) can decide to allow itself to be killed, in which case the "kill" is basically a request for it to shut itself down. This is one possible way to implement the halt command, though I'm not aware of any init that does that.

On a Mac, killing launchd (its init analogue) with signal 15 (SIGTERM) will immediately reboot the system, without bothering to shut down running programs cleanly. Killing it with the uncatchable signal 9 (SIGKILL) does nothing, showing that Mac's kill() semantics are the same as Linux's in this respect.

At the moment, I don't have a Linux box handy that I'm willing to experiment with, so the question of what Linux's init does with a SIGTERM will have to wait. And with init replacement projects like Upstart and Systemd being popular these days, the answer could be variable.

UPDATE: On Linux, init explicitly ignores SIGTERM, so it does nothing. @jsbillings has information on what Upstart and Systemd do.


The SysV init ignores SIGKILL or SIGTERM signals. The only signal that causes a change in state is SIGPWR as far as I can tell, which schedules a power-related shutdown.

It appears that Upstart and Systemd also do not respond to SIGKILL, and from my test, it appears that a SIGTERM causes upstart and systemd to re-exec.

I'm not sure what the other answerers are running but I'm pretty sure you can't kill -9 (SIGKILL) or kill -15 (SIGTERM) init (pid 1). Most likely, if you were able to, you'd get a kernel panic because init unexpectedly exited with a non-zero exit code, which would be less than ideal. It doesn't shut down your computer, or cause it to reboot.


You can restart the init process. This is useful for making changes to inittab without having to reboot.

kill -HUP 1

Source: http://www.cyberciti.biz/faq/linux-unix-kill-hup-1-reread-etcinittab-file/

Tags:

Root

Init