supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM>
To: supervision@list.skarnet.org
Subject: Re: runit SIGPWR support
Date: Sat, 29 Feb 2020 13:44:35 +0000	[thread overview]
Message-ID: <d0326094-e2ca-1467-6445-fb4471680b91@NTLWorld.COM> (raw)
In-Reply-To: <20200228094541.GA2429@cube>

Alex Suykov:

> Just for reference, I checked apcupsd sources.
>

That was not nearly enough research, and your conclusion is ill-founded.

The SIGPWR signal, from before Linux even existed, has always meant 
"something has happened with the power".  In AT&T Unix System 5 books it 
is conventionally described as "power fail/restart".  The "something" 
can include *that the power has been restored*.  And indeed, this has 
been its long-time use, on AT&T Unix and on Linux.   Miquel van 
Smoorenbug's original powerd daemon (which later became Tom Webster's 
genpowerd), for just one example, sent a SIGPWR to process 1 and 
beforehand wrote *what that meant* into /etc/powerstatus, which could be 
"LOW", "FAIL", or "OK".  A. B. Prasad's powerh, a trap handler for 
snmptrapd, did the same.  And there are several others over the years.

* https://linuxgazette.net/issue83/prasad.html

(Indeed, on several operating systems, including HP-UX and SunOS, SIGPWR 
sent to a process other than process #1 *only* meant "power has been 
restored", and did not have the power fail meaning at all.  Programs 
were expected to reinitialize after power comes back in their SIGPWR 
handlers.  A full-screen TUI program would re-draw its UI, for example, 
on the assumption that the local terminals had lost power as well and 
were currently showing blank screens.)

It is quite wrongheaded to think that this can be completely changed 
into a "shut down and power off" command, for that reason and others 
besides.  Other reasons include that existing systems *already define 
different signals to mean that*.  There is an existing mechanism 
already.  Several, in fact.  They need more than one signal, too.  
systemd (and the nosh toolset's system-manager which has compatible 
signalling here) uses two of the real-time signals to mean "shut down 
and power off", one to trigger the service changes, and the other to 
finalize the procedure.  There's no convincing case for either the 
systemd authors or me to change, given that SIGPWR has already meant 
something else for a long time and changing it would conflict with 
existing programs that we want to interoperate with.  There's a strongly 
convincing case to *avoid* changing SIGPWR, in fact.

The simple truth is that if you are using SIGPWR to mean only a "power 
failed" event, you aren't using it correctly.  van Smoorenburg init went 
and looked into /etc/powerstatus and acted accordingly, and still does 
so *to this day*, albeit that the file is now located under /var/run.  
(The systemd people and I both provide infrastructure only.  We define a 
target that is activated, but not what services that target invokes; and 
we leave it up to the third-party services to determine what the power 
change event actually is.)  Send a SIGPWR to process 1 without writing 
/run/powerstatus means that you'll get the last power change event set 
by the person that *did* use the signal properly.

Moreover, not only is there an existing mechanism in such programs, 
there are *several* existing mechanisms.  And they don't even all use 
signals.  The program being run could be anything, not just 
system-manager, or runit-init, or systemd, or finit, or even one of the 
several specialized programs designed solely to be process #1 of a 
container.  *Even just those* do not all use signals.

* https://unix.stackexchange.com/a/191875/5132

In the case of van Smoorenburg init and Joachim Nilsson's finit, there 
is a private API for commanding system state changes, idiosyncratic to 
just those softwares (and not compatible even across the twain), 
involving sending messages along a FIFO that process #1 is reading the 
other end of.  Ironically, Karl M. Hegbloom augmented genpowerd back in 
1998 to optionally use this API, which is more expansive than the 
comparatively small signal API that van Smoorenburg init has.  To 
properly use van Smoorenburg init or Nilsson finit in a container, you 
have to configure the container manager to *do something else instead of 
sending signals at all* to send it system management commands such as 
"shut down and halt/restart/poweroff/powercycle", as the API for 
commanding these is not signals.  The right place to handle all of these 
variances is in the container manager's configuration settings.

* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=23007#25

If you want to have some sort of "shut down and 
halt/restart/poweroff/powercycle" API between a container manager and 
process #1 inside a container, slightly absurd that the idea is for 
something that isn't a fully-fledged virtual machine with a virtual 
power supply, it is the program that is run that dictates the protocol 
to you, *not* you that dictates to the program being run.  The correct 
course of action is to tailor the container manager to the particular 
program, not try to make all programs, decades after the fact, suddenly 
discard and incompatibly overwrite the long-established, event not 
command, meaning of SIGPWR.



  parent reply	other threads:[~2020-02-29 13:44 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1beb6e35-d4be-60b8-fc52-af666c4fffe3@gmx.com>
2020-02-12 14:25 ` innerspacepilot
2020-02-12 21:54   ` Colin Booth
2020-02-12 22:16     ` Dewayne Geraghty
2020-02-14  9:38     ` Jeff
2020-02-14 12:38       ` Steve Litt
2020-02-15 10:47       ` fungal-net
2020-02-14 10:08     ` Jeff
2020-02-14 10:46     ` Jeff
2020-02-14 12:29       ` innerspacepilot
2020-02-14 12:45         ` Steve Litt
     [not found]           ` <CALZWFRLvtofWfP4kzxJ8_8_K3nzebPjCR-NsJ2MU22cSuaOLng@mail.gmail.com>
     [not found]             ` <20200214182241.15614126@mydesk.domain.cxm>
2020-02-17 19:46               ` Cameron Nemo
2020-02-23 16:11                 ` Jeff
2020-02-17 14:39         ` Jeff
2020-02-14 14:02       ` Casper Ti. Vector
2020-02-17 14:45     ` Jeff
2020-02-17 14:50       ` Jeff
2020-02-14 13:15   ` Casper Ti. Vector
2020-02-14 13:39     ` innerspacepilot
2020-02-14 13:57       ` Casper Ti. Vector
2020-02-14 14:06         ` innerspacepilot
2020-02-14 14:25           ` Casper Ti. Vector
2020-02-14 18:30       ` Laurent Bercot
2020-02-17 10:00         ` innerspacepilot
2020-02-17 15:13           ` Jeff
2020-02-18  9:39             ` Laurent Bercot
2020-02-20 20:39               ` Serge E. Hallyn
2020-02-23 16:51               ` Jeff
2020-02-23 23:53                 ` Laurent Bercot
2020-02-24  6:31                   ` innerspacepilot
2020-02-24 10:23                     ` Laurent Bercot
2020-02-24 13:00                       ` Jeff
2020-02-24 19:53                         ` Laurent Bercot
2020-02-24 13:12                       ` innerspacepilot
2020-02-24 15:26                         ` Serge E. Hallyn
2020-02-26  8:07                           ` innerspacepilot
2020-02-28  6:39                             ` Jan Braun
2020-02-28  9:45                               ` Alex Suykov
2020-02-28 23:50                                 ` fungal-net
2020-02-29 13:44                                 ` Jonathan de Boyne Pollard [this message]
2020-02-29 18:20                             ` Guillermo
2020-03-06 20:07                               ` innerspacepilot
2020-03-06 20:09                               ` innerspacepilot
2020-02-25  8:39                       ` Jonathan de Boyne Pollard
2020-02-24 21:13                   ` Guillermo
2020-02-24 22:25                     ` Laurent Bercot
2020-02-24 22:49                       ` Laurent Bercot
2020-02-24 23:08                         ` Guillermo
2020-02-25  1:48                           ` Laurent Bercot
2020-02-25  9:08                             ` Jonathan de Boyne Pollard
2020-02-25 18:38                               ` Guillermo
2020-03-16 12:49                               ` Jeff
2020-03-16 17:13                               ` Jeff
2020-02-24 23:03                       ` Guillermo
2020-03-16 12:31                       ` Jeff
2020-03-16 18:03                         ` Laurent Bercot
2020-02-23 17:31               ` Jeff
2020-02-24  0:33                 ` Laurent Bercot
2020-02-14 19:08   ` John W Higgins
2020-02-14 23:18     ` Laurent Bercot
2020-02-14 23:38       ` John W Higgins
2020-02-15  2:15         ` Laurent Bercot
2020-04-14 16:57 Maxim Vetsalo
  -- strict thread matches above, loose matches on Subject: below --
2020-01-23 20:44 innerspacepilot
2020-01-31  4:39 ` Colin Booth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0326094-e2ca-1467-6445-fb4471680b91@NTLWorld.COM \
    --to=j.deboynepollard-newsgroups@ntlworld.com \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).