On Mon, 11 Mar 2019 20:51:29 +0100 Andras Korn <[email protected]> wrote: > On Mon, Mar 11, 2019 at 06:12:06PM +0000, Dmitry Bogatov wrote: > > > > On Fri, Mar 08, 2019 at 02:39:47PM +0000, Dmitry Bogatov wrote: > > > > [2019-03-07 12:57] Andras Korn <[email protected]> > > > > > part 1 text/plain 218 > > > > > Sorry, I sent an earlier version of the patch by mistake. > > > > > > > > > > I'm attaching the correct one, which I tested and which works for me. > > > > > [...] > > > > > - if (sigc && (stat(STOPIT, &s) != -1) && (s.st_mode & S_IXUSR)) { > > > > > + if ((sigp) || (sigc && (stat(STOPIT, &s) != -1) && (s.st_mode & S_IXUSR))) { > > > > > > > > As far as I can tell by glance on patch, you want SIGPWR trigger reboot. > > > > If so, why don't you create REBOOT file in, say, /etc/rc.local and make > > > > lxc controller to send SIGCONT? > > > > > > No -- I want SIGPWR to trigger a halt. > > > > > > For the purposes of LXC, any signal will do; I just need for a signal to > > > trigger a shutdown regardless of the permissions on runit.stopit and > > > runit.reboot. > > > > Halt. Fine. But why can't you pre-provision you container with apporiate > > `stop.*' file with apporiate permissions? > > Because that adds complexity elsewhere -- /etc/runit/1 as shipped creates > /run/runit.stopit with mode 0, so either all containers would need ot have a > custom /etc/runit/1, or run a custom script to chmod 100 /run/runit.stopit > on every boot, or have an immutable /run/runit.stopit. > > It's not just about me; this affects everyone who wants to use runit inside > an lxc container. > > My goal is to make using runit as hassle-free as possible, without > sacrificing any of its core values. > > > > > By the way, SIGPWR is not in POSIX, according to signal(7). > > > > > > You're right; in that case, maybe we can use SIGQUIT? > > > > SIGTERM feels better, imho. TERM is graceful termination, while SIGQUIT > > creates coredump. By default. > > SIGPWR would be nice to use as the halt signal because it's the lxc default, > so that runit could be a drop-in replacement for sysvinit in LXC containers.
We should recognize that SIGPWR was chosen in a fairly arbitrary way. Of course, SIGPWR is in use today by LXC and powerstatd so it is useful to support. > > If we're not going to use SIGPWR it's pretty much all the same which signal > we use, because it will need to be configured explicitly in LXC (but that's > acceptable -- POSIX is important enough). > > > But this naming only matters if you explain to me, how solution not > > involving changing C code does not suffice. Two lines for convenience in > > this case, three there -- and we all know where it ends. > > I'm sorry, I don't buy the slippery slope argument. I'm not adding a DNS > resolver, a DHCP client or a QR encoder, merely making the user interface a > tiny bit more similar to sysvinit's, to make integration easier. This is > entirely in line with The Unix Way: making one program a drop-in replacement > for another such that other programs interfacing with them don't see a > difference unless they need to. It's why bzip2 and gzip take most of the You are taking a previously portable codebase and making it not portable. As a distribution patch, this might be acceptable. However it is an unfortunate compromise. Personally, I elect to replace the runit-init program entirely and only use the supervision suite. There is absolutely zero reason for an init system to call reboot(2). It is simply unnecessary. I have written a guide to do exactly this. It leverages two small C programs: * linit: * Reaps zombies * Ignores SIGCHLD, preventing new zombies * Sets up signal handlers for SIGINT and SIGPWR that spawn hooks * Spawns a boot hook * Calls pause() * lreboot: calls reboot(2) The rest is simply some scripting to emulate what runit-init does. Please review the guide and source code for the above C programs: https://gitlab.com/chinstrap/linit/blob/master/README.runit.md Regards, -- Cameron Nemo

