From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2880 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Cameron Nemo Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: runit SIGPWR support Date: Mon, 17 Feb 2020 11:46:15 -0800 Message-ID: References: <1beb6e35-d4be-60b8-fc52-af666c4fffe3@gmx.com> <20200212215427.GG12551@cathexis.xen.prgmr.com> <7102151581677176@myt2-dd3598211d70.qloud-c.yandex.net> <2b39fcd3-2954-f4be-94cc-7b089e2e2e09@gmx.com> <20200214074520.674d8c19@mydesk.domain.cxm> <20200214182241.15614126@mydesk.domain.cxm> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="3921"; mail-complaints-to="usenet@ciao.gmane.io" Cc: supervision@list.skarnet.org To: Steve Litt Original-X-From: supervision-return-2469-gcsg-supervision=m.gmane-mx.org@list.skarnet.org Mon Feb 17 20:46:25 2020 Return-path: Envelope-to: gcsg-supervision@m.gmane-mx.org Original-Received: from alyss.skarnet.org ([95.142.172.232]) by ciao.gmane.io with smtp (Exim 4.92) (envelope-from ) id 1j3mLY-0000mH-Pb for gcsg-supervision@m.gmane-mx.org; Mon, 17 Feb 2020 20:46:24 +0100 Original-Received: (qmail 15771 invoked by uid 89); 17 Feb 2020 19:46:45 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Original-Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Original-Received: (qmail 15759 invoked from network); 17 Feb 2020 19:46:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7PUIqaxQszhuc+W5DK+YyvpyzeeA9veR1C2Lvr034EU=; b=jdKUtmaPD57Slk9uEHmvHAUxwJTB357CSmWgBgiC2OW3z7LnvaIagOMu5K3VW3+PSC j31MxcGdR8FP0qwohWxEQCz0G7bvWUHznMBWG1fhHCZTQ+ZwQehlVfqbJOnLQYUZLw4D 8X6OHZpKzgmoZcjfig4Den1EAYfQblq7/KcWG0C0IUlCW8BfbmzNeI/maAMPz0QNCp6+ 8mD7Dh0Kj4T53RfHx/RqwAj+PQ6ZMBMDz5vMXNHG3byJyy9zsWSWQoRce1KcxDRn3Rc+ 5gmE/OhwjH+d6KHho3mmH9ZyaxMzeUGrz7wHJIYGHnTil6nGQtEbe6XsBO7F0MM0lD29 GZVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7PUIqaxQszhuc+W5DK+YyvpyzeeA9veR1C2Lvr034EU=; b=O52j1a/7EUzW1dkbCtkfVpFsdnYo/t+675bdTc80rrs1e1ebPriI7PpADasldae9ci VW6/kPtQB2Sm2mv0xDWktB4QsnhSVHjMi1J9tb/GBou/1jXqqFFYNjodNKtOI7SqCFu+ CS6+h0EjugUi3/dJwgsgRigWGiPM+7DQGK6rf6R47CF55G0H7PGVWhqH9lcrDor7usnX 07LrdyuDxSO45w8mg6JTVybaqdIwDVLhwuyedOuUaBQa6sYmL6+yPC0bgUjrzWlT8L8n FpXc/7cMhYRQHHw+lXcrqTq4iyB/SKDGFY4QQ61RUg+z93ECZ82EZnngID883hwkjlNN BsVQ== X-Gm-Message-State: APjAAAWEbTxep+s3qBU1gKl88pV1SfWuNKpKtmRNW6A/YKgUYCUDJtXu sudFY6a/h9UmoynhNRcVJlXDKtIIJS/yltmObvQ= X-Google-Smtp-Source: APXvYqxMQBomRFlEBzv8Mr+p41cwgkWne1MdFs3Sk8kxaKUqQFDzSdP3yNxYozCRInY2AgbEO8OQu6uDV1K/ADYX+RA= X-Received: by 2002:a05:620a:542:: with SMTP id o2mr15704949qko.318.1581968777010; Mon, 17 Feb 2020 11:46:17 -0800 (PST) In-Reply-To: <20200214182241.15614126@mydesk.domain.cxm> Xref: news.gmane.io gmane.comp.sysutils.supervision.general:2880 Archived-At: On Fri, Feb 14, 2020 at 3:22 PM Steve Litt wrote: > > On Fri, 14 Feb 2020 05:18:33 -0800 > Cameron Nemo wrote: > > > On Fri, Feb 14, 2020 at 4:45 AM Steve Litt > > 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