[Toybox] reboot: signal init, add -f to bypass

Isaac Dunham ibid.ag at gmail.com
Sat Mar 28 13:02:05 PDT 2015


reboot: signal init, add -f option to call reboot();
init: use SIGINT, use xsignal()

Now that oneit supports the same signals as our "sysv"-init for shutdown,
make reboot et al. signal pid 1 with the appropriate signal.
Of these signals, only SIGINT works with sysvinit 2.88, causing a reboot.
The others are only supported in Busybox init.

Also, make init accept SIGINT and use xsignal().
--
* I said init worked for me; that was with musl, where signal() is
equivalent to xsignal(). With _XOPEN_SOURCE < 700 / on glibc,
bsd_signal() is equivalent.
* Behavior of sysvinit/shutdown/reboot/halt/poweroff:
 According to the manpage, reboot/shutdown/poweroff call shutdown(8)
unless -f is passed. Reading the strace -f output, I'm not sure if that
happens but it writes a 384-byte message to the /run/initctl fifo
(formerly /dev/initctl).
 If you want to experiment on a sysvinit system, the simple way is to
determine whether initctl is in /dev or /run;
start a shell in a private mount namespace;
mount -o bind,private an empty file over initctl; and
then run the command you want, and use hd or such to examine the file.
 On sysvinit, only 3 signals do anything:
SIGINT:	reboot
SIGPWR: read /etc/powerstatus, and take action based on content:
 'O'	-	run "powerokwait" entries in inittab
 'L'	-	run "powerfailnow" entries
 'F'/default -	run "powerwait" and "powerfail" entries.
SIGSEGV: seems to basically stop polling initctl and wait for one of
the three signals

The manpage says to not use SIGPWR for new code.


Thanks,
Isaac Dunham
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reboot.diff
Type: text/x-diff
Size: 2593 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150328/d3b1324e/attachment-0004.diff>


More information about the Toybox mailing list