From 90989cf9c0381c28a0285320518e570da8a6bd00 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 10 Jan 2022 20:37:11 +0000 Subject: Update s6-svscan-1.html to reflect how s6-l-i works Signed-off-by: Laurent Bercot --- doc/s6-svscan-1.html | 105 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/doc/s6-svscan-1.html b/doc/s6-svscan-1.html index a57e199..c168c4d 100644 --- a/doc/s6-svscan-1.html +++ b/doc/s6-svscan-1.html @@ -38,7 +38,7 @@ bit of understanding of what is going on.

- The life of a Unix machine has three stages: + The life of a Unix machine has four stages:

    @@ -58,12 +58,14 @@ to add or remove services. This phase ends when the administrator requires a shutdown.
  1. The shutdown phase. Everything is cleaned up, services are stopped, filesystems are unmounted, the machine is getting ready to be -halted. During this phase, everything but the shutdown procedure gets -killed - the only surefire way to kill everything is kill -9 -1, -and only process 1 can survive it and keep working: it's only logical -that the shutdown procedure, or at least the shutdown procedure from -the kill -9 -1 on and until the final poweroff or reboot -command, is performed by process 1.
  2. +halted. At the end of this phase, all processes are killed, first with +a SIGTERM, then with a SIGKILL (to catch processes that resist SIGTERM). +The only processes that survive it are process 1; if this process is +s6-svscan and its scandir +is not empty, then the supervision tree is restarted. +
  3. The hardware shutdown phase. The system clock is stored, +filesystems are unmounted, and the system call that reboots the machine or +powers it off is called.

@@ -87,8 +89,10 @@ Even the runit program, designed with supervision in mind, remains as process 1 all the time; at least runit makes things simple by clearly separating the three stages and delegating every stage's work to a different script that is -not run as process 1. (This requires very careful handling of the -kill -9 -1 part of stage 3, though.) +not run as process 1. (Since runit does not distinguish between +stage 3 and stage 4, it needs very careful handling of the +kill -9 -1 part of stage 3: getting /etc/runit/3 killed +before it unmounts the filesystems would be bad.)

@@ -104,7 +108,7 @@ stages and delegating every stage's work to a different script that is init does not have the right to die, but fortunately, it has the right to execve()! During stage 2, why use precious RAM, or at best, swap space, to store data -that are only relevant to stages 1 or 3? It only makes sense to have an +that are only relevant to stages 1 or 3-4? It only makes sense to have an init process that handles stage 1, then executes into an init process that handles stage 2, and when told to shutdown, this "stage 2" init executes into a "stage 3" init which just performs shutdown. Just as runit does with the @@ -158,7 +162,7 @@ are some general design tips.