5 ms·
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. Thi
by munchhausen 13y ago
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.
- nailer 13y agoIt'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.
- srd 13y agoWhich won't matter if you're a normal user. If you're root - why are you using the job system to kill your jobs?
- belorn 13y agoI wonder what would happen if you used OOM_Killer on process ID 1.
- makomk 13y agoPID 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 13y agozx2c4@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.