#1016787 runit: improve patch to handle SIGPWR

Package:
runit
Source:
runit
Description:
system-wide service supervision
Submitter:
Lorenzo Puliti
Date:
2025-09-17 23:07:02 UTC
Severity:
normal
Tags:
#1016787#5
Date:
2022-08-07 13:31:39 UTC
From:
To:
The Debian package includes a patch to make runit shutdown when it receives
SIGPWR (upstream ignores the signal). The patch, apart from reacting to a
powerfailure event, is usefull when runit is used inside a container where
SIGPWR is sent to initiate shutdown.

I'm not happy with the current patch: it completely ignores the shutdown
runit logic, which is signal + mode check on a flag file. Also, ignore the
the signal or run a custom action are equally alternative valid options
to a forced shutdown.

The patch could be improved in one of the following way

A) when SIGPWR is catch, check for a /etc/runit/pwrfail flag file, and
   ignore the signal if the file doesn't exists and it's not executable
   (this way the signal can be ignored)

B) Use /etc/runit/pwrfail script that works in the same way of
   /etc/runit/ctrlaltdel (same as A, but allow for a custom action)

#1016787#8
Date:
2025-06-27 17:58:28 UTC
From:
To:
Hello,

Bug #1016787 in runit reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/debian/runit/-/commit/3b6e0d2a6f955008b08310831a2cfdb94fcd1d2b
------------------------------------------------------------------------
d/patches: rework SIGPWR patch

old patch forced runit to shutdown as SIGPWR was received; new one
does uses a similar logic to the ctrl-alt-del block, testing
(and running) the /etc/runit/pwrfail file. Compared to the
ctrl-alt-del logic the patch has the following changes:
* it adds the x bit to /etc/runit/stopit (if it exists) before
  forking for pwrfail (this imply that it defaults to shutdown if
  pwrfail script does nothing);
* it tries to fork for pwrfail script only once, instead of a while
  loop with a sleep 5; getting stuck in a while loop in case fork
  fails can be conterproductive in case of power fail. This is the
  reason why the mode of /etc/runit/stopit is changed before forking.

Compared to the previous one, with this patch the user can:
- disable SIGPWR, for example by 'chmod -x /etc/runit/pwrfail'
- reboot instead of shutdown, by removing the x bit on 'stopit'
  and adding it to 'reboot' (can be done in pwrfail script)
- program an alternative or additional action in pwrfail script

Closes: #1016787
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1016787

#1016787#13
Date:
2025-09-15 14:43:30 UTC
From:
To:
Hello,

Bug #1016787 in runit reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/debian/runit/-/commit/1117f0f00801b9d9b194e0052d2ec52697898135
------------------------------------------------------------------------
d/patches: rework SIGPWR patch

old patch forced runit to shutdown as SIGPWR was received; new one
does uses a similar logic to the ctrl-alt-del block, testing
(and running) the /etc/runit/pwrfail file. Compared to the
ctrl-alt-del logic the patch has the following changes:
* it adds the x bit to /etc/runit/stopit (if it exists) before
  forking for pwrfail (this imply that it defaults to shutdown if
  pwrfail script does nothing);
* it tries to fork for pwrfail script only once, instead of a while
  loop with a sleep 5; getting stuck in a while loop in case fork
  fails can be conterproductive in case of power fail. This is the
  reason why the mode of /etc/runit/stopit is changed before forking.

Compared to the previous one, with this patch the user can:
- disable SIGPWR, for example by 'chmod -x /etc/runit/pwrfail'
- reboot instead of shutdown, by removing the x bit on 'stopit'
  and adding it to 'reboot' (can be done in pwrfail script)
- program an alternative or additional action in pwrfail script

Closes: #1016787
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1016787

#1016787#18
Date:
2025-09-17 23:05:02 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
runit, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1016787@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Lorenzo Puliti <plorenzo@disroot.org> (supplier of updated runit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Wed, 17 Sep 2025 22:59:44 +0200
Source: runit
Architecture: source
Version: 2.2.0-4
Distribution: unstable
Urgency: medium
Maintainer: Lorenzo Puliti <plorenzo@disroot.org>
Changed-By: Lorenzo Puliti <plorenzo@disroot.org>
Closes: 1016787
Changes:
 runit (2.2.0-4) unstable; urgency=medium
 .
   * d/patches:
     - allow runsvchdir to get working directory from env
     - add patches from upstream devground branch
     - rework SIGPWR patch (Closes: #1016787)
     - refresh patch 0021 and 0025
   * add a /etc/runit/pwrfail script to activate SIGPWR
   * runsvchdir and update-service: move from /sbin to /bin
   * cpsv:
      - adapt 'p' for multi-instance services
      - adapt 'p' for user services
      - try to adapt 'd' for multi and user instances
      - create supervise as directory for user services
      - 's': map runit's {multi|user}-instances to systemd and
          sysv conterparts
   * update-service: adapt for user services
   * sysv.override: map runit's multi instance default to sysv
   * bash-completions:
      - update 'sv' for user services/ non-root usage
      - update 'update-service' for user services/ non-root usage
   * temporary build with gcc-14
   * NEWS for runit and runit-init users
Checksums-Sha1:
 171951544bfc21687b3c901c6d86577009cb9fcc 2211 runit_2.2.0-4.dsc
 7d860d760ea7d2bfaf6393ab50be96558e653ac7 75192 runit_2.2.0-4.debian.tar.xz
 0e97be60927dca309bef5dae0004210f147d0119 7386 runit_2.2.0-4_amd64.buildinfo
Checksums-Sha256:
 a17518855c473af25c4a00b33d096b3cc44a26c139870f227e393f7ed06b6dbc 2211 runit_2.2.0-4.dsc
 79ecc508b2a0feb4e9ad90dc739a1cbf73a1e6b37752f1f3eedc1617a5235be8 75192 runit_2.2.0-4.debian.tar.xz
 65e47d2934453c456ad183261c9381a37981e80f7da9344565bf21c7424ed273 7386 runit_2.2.0-4_amd64.buildinfo
Files:
 22004a6bcdc8d187e3188e065855d8de 2211 admin optional runit_2.2.0-4.dsc
 9d413bcf7689f59a52f92c60f4b01d0b 75192 admin optional runit_2.2.0-4.debian.tar.xz
 fe41604f6259e9d948003f61e8ff0a2b 7386 admin optional runit_2.2.0-4_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE2ji91PGnrxOd1bVNxxYb07RU7gMFAmjLOKkACgkQxxYb07RU
7gNt5Q/+OFQDfgpY6n/QF3LouYnjGE19JYJu/we1FH3AGZZ/iyZ2qh9zVx0RMpxT
Ex/cjV8RXbdBUTBpxrM1yuJpQBvZqTdmJ1g47UGF9uJZylcmzLTzM1Q1HNK7rqdV
px4JEOMGZ+jW4SFCMzqj0Pkvr9OikL9ezMNc4DCekgVEsgXIHIncYi7SHampahhy
kj60vMLjrwJqDljiXJVJofmNJwyrhHWZ8KDEtZKcImbElZXMk8FDhVZyKHXWJF9t
N88usr253C8bURunuxKUqWHirFBJLb8D1Xws/rIQKA+1ttzFwjzX5jCGnRNt02AA
NYcDg+WQh/fo9SyCcnIC1VB2XYl7vVCgk5Lcq76z2w17PVLbKXU0NyUN6ooasj35
9EcZ8wZ1HIB23LEa+LpDcalXGudkWFFFIF+tsRqskHp5S3hXdcEQgUvR62QJpnSC
WEIKo0HLzitzKPRaRpCVfklSgrOnFRHnlG5kvoLfWaYMzQPDrySmpdRcualJl7yg
ui7AJZtZL/bglkIB/mbgSdbpTe2HFiLolhW0bLLQgCTf2IoL2GwlTtijo1iRyxww
yYcVXKrSjRyWcg4BfBpFM1uEUj8p35zv4pCFBojw72EwUaXHQ68ZsJUeiWIF4aDi
qg+xOgwalSIrQX7+QE/yrMJSO9vjTRMmcpRvMSuSlvGGuraB1RM=
=G8m7
-----END PGP SIGNATURE-----