commit e4d0708ae987518eae2c136baefdf5ee7a17f90a
parent 8e3dcf2c3c08b95dd51a5b8d213c363cf304c8d1
Author: Jan Pobříslo <ccx@te2000.cz>
Date: Tue, 15 Nov 2022 11:18:12 +0100
Rework finish procedure so /run gets cleaned up
Diffstat:
6 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/install b/install
@@ -69,6 +69,7 @@ $qc/ifelse { $qc/s6-test -e /run/service } {
$qc/foreground { $qc/s6-echo -- "ERROR: /run/s6-rc already exists" }
false
}
+if { mkdir -p /run/uncaught-logs }
if {
elglob GLOB $(q "$(realpath "$src")")/run-image/* cp -a \$GLOB /run
}
diff --git a/run-image/service/.s6-svscan/SIGHUP b/run-image/service/.s6-svscan/SIGHUP
@@ -1,4 +1,4 @@
#!/bin/execlineb -P
-foreground { redirfd -w 1 "/run"/file\ created\ by\ s6-linux-init,\ storing\ a\ container's\ exit\ code s6-echo -- 0 }
+foreground { "/current/init/scripts/rc.shutdown" }
s6-svscanctl -b "/run"/service
diff --git a/run-image/service/.s6-svscan/SIGINT b/run-image/service/.s6-svscan/SIGINT
@@ -1,4 +1,4 @@
#!/bin/execlineb -P
-foreground { redirfd -w 1 "/run"/file\ created\ by\ s6-linux-init,\ storing\ a\ container's\ exit\ code s6-echo -- 1 }
+foreground { "/current/init/scripts/rc.shutdown" }
s6-svscanctl -b "/run"/service
diff --git a/run-image/service/.s6-svscan/finish b/run-image/service/.s6-svscan/finish
@@ -1,16 +1,17 @@
-#!/bin/execlineb -S0
-
-ifelse { redirfd -w 2 /dev/null redirfd -r 0 "/run"/file\ created\ by\ s6-linux-init,\ storing\ a\ container's\ exit\ code exit 0 }
-{ redirfd -r 0 "/run"/file\ created\ by\ s6-linux-init,\ storing\ a\ container's\ exit\ code withstdinas -in CODE foreground { s6-rmrf "/run"/file\ created\ by\ s6-linux-init,\ storing\ a\ container's\ exit\ code } importas -ui CODE CODE exit ${CODE} }
+#!/bin/sh
cd /
-#redirfd -w 2 /dev/console
-#fdmove -c 1 2
-foreground { s6-svc -X -- "/run"/service/s6-svscan-log }
-unexport ?
-wait -r -- { }
-foreground { s6-echo "Sending all processes the TERM signal." }
-foreground { s6-nuke -th }
-s6-sleep -m -- 2000
-foreground { s6-echo "Sending all processes the KILL signal." }
-foreground { s6-nuke -k }
-wait -t 2000 { }
+/command/s6-echo "s6:finish: Terminating all remaining services"
+for d in /run/service/*; do
+ case $d in
+ (*/s6-svscan-log)
+ /command/s6-svc -x -- "$d"
+ ;;
+ (*)
+ /command/s6-svc -kx -- "$d"
+ ;;
+ esac
+done
+/command/s6-echo "s6:finish: removing /run/s6-rc"
+rm /run/s6-rc
+/command/s6-echo "s6:finish: removing /run/service"
+rm -rxf /run/service
diff --git a/run-image/service/s6-svscan-log/run b/run-image/service/s6-svscan-log/run
@@ -1,5 +1,6 @@
#!/command/execlineb -P
/command/redirfd -w 1 /dev/null
+/command/redirfd -w 2 /dev/console
/command/redirfd -rnb 0 fifo
-/command/s6-log -bpd3 -- t /run/uncaught-logs
+/command/s6-log -bd3 -- t /run/uncaught-logs
diff --git a/run-image/uncaught-logs/.keep b/run-image/uncaught-logs/.keep