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

From: <dan_at_telent.net>
Date: Mon, 20 Nov 2023 23:12:50 +0000

[ Apologies if this is a repost. I didn't see it in the archive
so I'm guessing the list silently drops mail from non-subscribers ]

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)
and resorted to reading the s6-linux-init-shutdown.c code

As far as I can tell, when it's ready to start shutting down it
performs these steps:

1) run the rc.shutdown (which in my case calls s6-rc change)

2) runs unsupervise_tree() which walks /run/service (except for
a few explicitly named special-case processes) and sends the
"d" command through /run/service/foo/supervise/control to the
s6-supervise process for each service

3) calls s6_svc_write("/run/service/.s6-svscan/control", "an", 2)
which triggers a rescan (not a terminate)

4) sends TERM and (after a delay) KILL to the destination -1

However, I don't think kill(-1, n) *works* for pid 1. At least on Linux.
If I look at kernel/signal.c (Linux 5.15.71) I see that
SYSCALL_DEFINE2(kill, ... ) (line 3800 or so) calls
kill_something_info() which in the case of -1 iterates for_each_process
but only acts on processes for which task_pid_vnr(p) > 1 - so I don't
believe this is sending anything to pid 1.

Is there some other call to send a "t" to the svscan fifo that I just
haven't found? I'm going to kick myself if so ...


-dan
Received on Tue Nov 21 2023 - 00:12:50 CET

This archive was generated by hypermail 2.4.0 : Tue Nov 21 2023 - 00:13:33 CET