On Fri, Feb 14, 2020 at 3:22 PM Steve Litt <sl...@troubleshooters.com> wrote: > > On Fri, 14 Feb 2020 05:18:33 -0800 > Cameron Nemo <camerontnor...@gmail.com> wrote: > > > On Fri, Feb 14, 2020 at 4:45 AM Steve Litt > > <sl...@troubleshooters.com> wrote: > > > > > > In my computer usage, I usually need about 5 minutes to gracefully > > > exit all my programs before powering down the computer, and I have > > > a 40 minute UPS. If this is done at all, I'd suggest a configurable > > > amount of time, with a visible countdown, telling the user to get > > > his or her affairs in order, and also a way to cancel the shutdown. > > > > > > The only reason I see to have the computer automatically power down > > > when signaled by the UPS is that I might not be home, but in that > > > case waiting 5 minutes wouldn't matter. > > > > Most init systems allow the SIGPWR behavior to be configured. > > This includes Upstart, systemd, and my own "little init": > > > > https://gitlab.com/chinstrap/linit#configuration > > > > I provide a guide for using linit with runit here, but the process is > > experimental: > > > > https://gitlab.com/chinstrap/linit/-/blob/master/README.runit.md > > > > Linit is packaged in Void Linux, and void images are available for > > LXD. Lastly I want to mention that lxc.signal.halt is not available > > with LXD. > > > > Regards, > > -- > > Cameron Nemo > > Hi Cameron, > > I'm very impressed with linit. In my 20 minute perusal it looks quite a > bit like Suckess Init, which I like. On line 54 you have > int linit_spawn(char * restrict path) { > > Is path the path to the rc file that linit forks off? I've never seen > char * restrict before: What does "restrict" mean?
I use the term hook, which could refer to /boot, /sigpwr, or /sigint. Roughly equivalent to an rc file. restrict keyword is described here: https://en.wikipedia.org/wiki/Restrict https://stackoverflow.com/questions/745870/realistic-usage-of-the-c99-restrict-keyword It is probably not useful in this case, but the posix_spawn API specifies it so I used it. > > I notice linit responds only to a couple signals, whereas Suckless > Init responds to: > { SIGUSR1, sigpoweroff }, > { SIGCHLD, sigreap }, > { SIGALRM, sigreap }, > { SIGINT, sigreboot }, > { SIGILL, sigillhandle}, > SIGUSR1: I am unaware of any linux tools which use that signal. I used SIGPWR specifically for compat with UPS tools and lxc/lxd. SIGCHLD: linit actually ignores this signal, which reaps the child. SIGALRM: because childs are implicitly reaped, there is no reason to include a tick from what I can tell. (i.e. this case never happens: https://git.suckless.org/sinit/commit/170d599d58efee6c9be675a85c6e435d68e8a2de.html) SIGINT: same behavior as sinit here. SIGILL: you must have added that. I would be curious to know why. > Actually, I think I might have put one of those in, but I don't think > you respond to most of them: Is there a reason? > > Anyway, I kind of like your linit PID1. Thanks. The only real novel details are that: - it calls pause() in the main loop - uses posix_spawn() to exec from signal handlers in a thread safe manner > Steve Regards, Cameron