s6-notify: support fd-based s6 notification protocol (#1466)

Dinit and s6 supervision suite are known to support this protocol.

See https://skarnet.org/software/s6/notifywhenup.html and
https://davmac.org/projects/dinit/man-pages-html/dinit-service.5.html#ready

Signed-off-by: Mobin Aydinfar <mobin@mobintestserver.ir>
This commit is contained in:
Mobin 2026-05-22 20:56:47 +03:30 committed by GitHub
parent b2401ff15a
commit 8c201b844e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -987,6 +987,10 @@ class SvcHub(object):
Daemon(self.sd_notify, "sd-notify")
zb = os.environ.get("S6_NOTIFY_FD")
if zb:
Daemon(self.s6_notify, "s6-notify", (zb,))
def _feature_test(self) -> None:
fok = []
fng = []
@ -1897,6 +1901,17 @@ class SvcHub(object):
except:
self.log("sd_notify", min_ex())
def s6_notify(self, zb: bytes) -> None:
try:
fd = int(zb)
if fd < 3:
raise Exception("value < 3")
os.write(fd, b"\n")
os.close(fd)
except:
t = "S6_NOTIFY_FD=%s:\n%s"
self.log("s6-notify", t % (zb, min_ex()), 1)
def log_stacks(self) -> None:
td = time.time() - self.tstack
if td < 300: