From ca8d2c96ea09cb33ff6fef33c0314c24fc6a026a Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 9 Dec 2020 18:19:21 +0000 Subject: Make it work with the new s6. Add s6-linux-init-nuke. --- src/init/s6-linux-init-maker.c | 7 +++++-- src/lib/s6_linux_init_logouthook.c | 2 +- src/misc/deps-exe/s6-linux-init-nuke | 0 src/misc/s6-linux-init-nuke.c | 8 ++++++++ src/shutdown/s6-linux-init-shutdownd.c | 4 ++-- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/misc/deps-exe/s6-linux-init-nuke create mode 100644 src/misc/s6-linux-init-nuke.c (limited to 'src') diff --git a/src/init/s6-linux-init-maker.c b/src/init/s6-linux-init-maker.c index 1e6de62..7c315a6 100644 --- a/src/init/s6-linux-init-maker.c +++ b/src/init/s6-linux-init-maker.c @@ -120,7 +120,8 @@ static int container_crash_script (buffer *b, char const *data) EXECLINE_EXTBINPREFIX "foreground\n{\n " EXECLINE_EXTBINPREFIX "fdmove -c 1 2\n " S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-echo -- \"s6-svscan crashed. Killing everything and exiting.\"\n}\n" - EXECLINE_EXTBINPREFIX "foreground { kill -9 -1 }\n" + EXECLINE_EXTBINPREFIX "foreground { " + S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-nuke }\n" EXECLINE_EXTBINPREFIX "wait { }\n" S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnp\n") >= 0 ; } @@ -134,6 +135,9 @@ static int container_exit_script (buffer *b, char const *data) EXECLINE_EXTBINPREFIX "multisubstitute\n{\n" " importas -uD0 -- EXITCODE exitcode\n " " importas -uDh -- HALTCODE haltcode\n}\n" + EXECLINE_EXTBINPREFIX "fdclose 1\n" + EXECLINE_EXTBINPREFIX "fdclose 2\n" + EXECLINE_EXTBINPREFIX "wait { }\n" EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = r } { " S6_LINUX_INIT_EXTBINPREFIX "s6-linux-init-hpr -fnr }\n" EXECLINE_EXTBINPREFIX "ifelse -X { test $HALTCODE = p } { " @@ -547,7 +551,6 @@ static inline void make_image (char const *base) auto_dir(base, "run-image/" SCANDIR, 0, 0, 0755) ; auto_dir(base, "run-image/" SCANDIR "/.s6-svscan", 0, 0, 0755) ; auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGTERM", &put_shebang_options, 0) ; - auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGHUP", &put_shebang_options, 0) ; auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGQUIT", &put_shebang_options, 0) ; auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGINT", &sig_script, "-r") ; auto_script(base, "run-image/" SCANDIR "/.s6-svscan/SIGUSR1", &sig_script, "-p") ; diff --git a/src/lib/s6_linux_init_logouthook.c b/src/lib/s6_linux_init_logouthook.c index 810f29b..cc6b11a 100644 --- a/src/lib/s6_linux_init_logouthook.c +++ b/src/lib/s6_linux_init_logouthook.c @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include #include #include "initctl.h" diff --git a/src/misc/deps-exe/s6-linux-init-nuke b/src/misc/deps-exe/s6-linux-init-nuke new file mode 100644 index 0000000..e69de29 diff --git a/src/misc/s6-linux-init-nuke.c b/src/misc/s6-linux-init-nuke.c new file mode 100644 index 0000000..93326e5 --- /dev/null +++ b/src/misc/s6-linux-init-nuke.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include + +int main (void) +{ + return kill(-1, SIGKILL) < 0 ; +} diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c index b646b5c..edf5adb 100644 --- a/src/shutdown/s6-linux-init-shutdownd.c +++ b/src/shutdown/s6-linux-init-shutdownd.c @@ -178,11 +178,11 @@ static inline void prepare_stage4 (char const *basedir, char what) if (buffer_puts(&b, "#!" EXECLINE_SHEBANGPREFIX "execlineb -P\n\n" EXECLINE_EXTBINPREFIX "foreground { " - S6_EXTBINPREFIX "s6-svc -Ox -- . }\n" + S6_EXTBINPREFIX "s6-svc -x -- . }\n" EXECLINE_EXTBINPREFIX "background\n{\n ") < 0 || (!nologger && buffer_puts(&b, EXECLINE_EXTBINPREFIX "foreground { " - S6_EXTBINPREFIX "s6-svc -Xh -- " SCANPREFIX LOGGER_SERVICEDIR " }\n ") < 0) + S6_EXTBINPREFIX "s6-svc -xc -- " SCANPREFIX LOGGER_SERVICEDIR " }\n ") < 0) || buffer_puts(&b, S6_EXTBINPREFIX "s6-svscanctl -b -- " SCANDIRFULL "\n}\n") < 0) strerr_diefu2sys(111, "write to ", STAGE4_FILE ".new") ; -- cgit v1.2.3