Re:Broken by design: systemd
by InclinedPlane on Monday February 10, 2014 @06:14AM
(#7210335)
See what happens when you kill PID 1 on a system using sysvinit.
[ Parent
| on HN ]
Re:Broken by design: systemd
by munchhausen on Monday February 10, 2014 @07:03AM
(#7210514)
On Linux, nothing:
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. (From kill(2))
In practice, you will find that:
kill(1, SIGKILL) = 0
results in exactly...no effect.It's also because Unix doesn't generally believe in being forgiving (or, UX in general):
someapp &
[job 1 backgrounded]
kill %1
(job 1 is killed - yep, you can use kill for jobs)
Miss a percent there? You've just sent a TERM to init.Which won't matter if you're a normal user. If you're root - why are you using the job system to kill your jobs?
> If you're root - why are you using the job system to kill your jobs?
Probably because you know the features of your shell and enjoy productivity.
Because thats a job for kill.
I wonder what would happen if you used OOM_Killer on process ID 1.
PID 1 is meant to be immune to the OOM killer. Last time I did development work in that area, it was also impossible to attach a debugger to PID 1 without patching the kernel, and although it worked I'm not sure how safe it was to do so.
zx2c4@thinkpad ~ $ sudo strace -p 1
Process 1 attached
select(11, [10], NULL, NULL, {1, 122329}) = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0}) = 0 (Timeout)
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(10, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
stat("/dev/initctl", {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
select(11, [10], NULL, NULL, {5, 0}^CProcess 1 detached
<detached ...>
Ptracing seems to work for me.