Re: How does s6-linux-init-shutdownd.c contact pid 1?

From: Laurent Bercot <>
Date: Tue, 21 Nov 2023 00:28:23 +0000

>I've been trying to find out why my "finish" script is not working
>(or perhaps it is working but not printing output anywhere I can see)

  The ways of shutdown are mysterious. :)

>However, I don't think kill(-1, n) *works* for pid 1.

  Indeed, it does not. That kill is supposed to be sent to every process
*except* s6-svscan, which will survive and restart the supervisor for
s6-linux-init-shutdownd, which will restart s6-linux-init-shutdownd,
which will then execute stage 4.

  If you're not in a container, stage 4 will unmount the filesystems
then hard halt/poweroff/reboot the machine.

  s6-linux-init-shutdownd never tells s6-svscan to exit, so if you're
running s6-linux-init, it's normal that your .s6-svscan/finish script
is not executed.

  The place where you want to hack things is /etc/,
which is run by the stage 4 script right before the hard reboot. At
this point nothing is mounted anymore and the process tree is only

  \_ s6-supervise s6-linux-init-shutdownd
      \_ foreground { } reboot

so you can do dirty stuff like "rm -f
&& s6-svc -dxwD /run/service/s6-linux-init-shutdownd &&
s6-svscanctl -b /run/service" which should clean up the s6-supervise
and the foreground, and give control to .s6-svscan/finish.

  Start your finish script with "wait { }" because s6-svscan will
exec into it before dies, and you don't want a zombie
hanging around.

Received on Tue Nov 21 2023 - 01:28:23 CET

This archive was generated by hypermail 2.4.0 : Tue Nov 21 2023 - 01:28:51 CET