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

Rob Landley rob at landley.net
Wed Aug 5 21:01:57 PDT 2015


On 03/28/2015 03:02 PM, Isaac Dunham wrote:
> 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;

In the absence of a spec _or_ historically consistent behavior, I'm
happy requiring toybox reboot and toybox init (or oneit) to only work
with each other.

Apparently the changes to oneit last release broke sparc, something to
do with pipes. Trying to track that down.

My can of worms with init (other than not having cleaned up
toys/pending/init.c yet, or migrated it to a pid 2 working with oneit)
is that I still have a pile of notes from when I talked to Lennart
Pottering at LinuxCon Japan that I haven't had a chance to go through.
Most of them are of the form "read this man page" or "look at this part
of this source file", but we worked out that I _can_ chop out a sane
subset of the behavior, and that's the important thing.

(Basically "systemd aware" daemons and such are told what to do via
environment variables, and you can set environment variables to
consistently demand a small subset of the behavior, which is then all
you have to implement.)

> 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.

Lovely.

Let's just worry about the signals for now. Containers let you direct
signals to a container-local PID 1. Yes you need to be container-local
root to send it, again: I'm ok with that. We can revisit this later.

Rob

 1438833717.0


More information about the Toybox mailing list