[PATCH] init: Add handshake to poweroff/reboot for signal handler setup

Deb McLemore debmc at linux.vnet.ibm.com
Wed Feb 14 03:29:21 UTC 2018


>From the original thread, we tried the suggestion, but when the do_execve is done from kernel_init

for Busybox /sbin/init (to start PID=1) all process zombies are flushed (the usermode helper that kicks

Busybox /sbin/poweroff started by PID=2, before PID=1 is do_execve'd from kernel init).  So when the line is crossed

when PID=1 begins all zombies and pre-work are flushed, so nothing is carried over into the life of PID=1

to synchronize with or detect when the signals are properly setup.  The only solution which worked was doing the abstract socket handshake which stays persistent across the boundary from PID=0 heritage to when PID=1 is properly instantiated.

proc_flush_task_mnt from linux/fs/proc/base.c


On 02/13/2018 08:32 PM, Laurent Bercot wrote:
>> Even when process=1 is started, it still leaves a window when the
>> signal handler setup has not been completed.
>
>  Yes, but you can still use kill(pid, 0) to check whether init is
> ready to receive signals: doublefork a zombie and repeatedly kill it
> with signal 0. When you get -1 ESRCH, it means init has reapt the
> zombie, so it's in its reaping loop, and at that point you know it
> has installed its signal handlers.
>
>  See http://lists.busybox.net/pipermail/busybox/2017-October/085888.html
>
>  That's arguably uglier than using abstract sockets, but it can
> be done without modifying the init code at all.
>
> -- 
>  Laurent
>



More information about the busybox mailing list