From 06d97dd40108bc685a4fab846cc156827534d15b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 8 Jun 2026 00:56:35 +0000 Subject: Add s6-svscanboot doc --- doc/s6-svscanboot.html | 131 ++++++++++++++++++++++++++++++++++++++++ src/supervision/s6-svscanboot.c | 13 ++-- 2 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 doc/s6-svscanboot.html diff --git a/doc/s6-svscanboot.html b/doc/s6-svscanboot.html new file mode 100644 index 0000000..5b2f225 --- /dev/null +++ b/doc/s6-svscanboot.html @@ -0,0 +1,131 @@ + + + + + + + s6: the s6-svscanboot program + + + + + + +

+s6
+Software
+www.skarnet.org +

+ +

The s6-svscanboot program

+ +

+s6-svscanboot starts a supervision tree, spearheaded by +s6-svscan, while logging its own output, +as well as the output of the tree's s6-supervise +processes, into a catch-all logger that it itself supervises. +

+ +

+In other words, it starts a self-sufficient, self-contained supervision tree, +that does not leak logs &emdash; apart from exceptionally rare error messages +from the catch-all logger itself. +

+ +

+s6-svscanboot is meant to be used when an external service manager +needs to start an s6 supervision tree. It prevents the supervision tree's logs +from either flooding the upper service manager or being lost entirely. +

+ +

Interface

+ +
+     s6-svscanboot [ -c devconsole ] [ -D catchalldir ] [ -m catchallmode ] [ -l catchalluser ] [ -o catchalloptions ] [ -d notif ] [ -X consoleholder ] [ -C services_max ] [ -L name_max ] [ -t rescan ] scandir
+
+ + + +

Exit codes

+ +
+
100
Wrong usage
+
111
System call failure
+
+ +

+On success, s6-svscanboot does not exit, but execs into +s6-svscan instead, which is supposed to remain +running until the administrator decides to stop it or the machine shuts down. +

+ + +

Options

+ +
+
-c console, --console=console
+
Send the catch-all logger's error messages to device console. These +will be the only error messages from the supervision tree that will not go into +the catch-all logger. By default, this device is whatever s6-svscanboot +stderr points to at invocation time.
+ +
-D dir, --catchall-directory=dir
+
The directory where the s6-log catch-all will write +and rotate the supervision tree's logs. Default is /run/uncaught-logs.
+ +
-m mode, --catchall-mode=mode
+
What permissions the catch-all directory shall have. Default is 02750.
+ +
-l user, --catchall-user=user
+
What user the catch-all logger shall run as. Default is the same user as +the supervision tree, i.e. the user that launched s6-svscanboot. This +option should only be used by root.
+ +
-o options, --catchall-options=options
+
What control and selection directives the s6-log program +shall use for logging its input. Directives should be separated by spaces. The +options string will appear verbatim in the scandir/s6-svscan-log/run +script, so caution should be used when using this option. Default is t.
+ +
-d notif, --notification-fd=notif
+
Notify file descriptor notif when s6-svscan is ready. +This option is passed directly to s6-svscan.
+ +
-C services_max, --services-max=services_max
+
Maintain services for up to services_max service directories, including loggers. +This option is passed directly to s6-svscan.
+ +
-L name_max, --name-max=name_max
+
The maximum length of a name in the scan directory. +This option is passed directly to s6-svscan.
+ +
-t rescan, --timeout=rescan
+
Perform a scan every rescan milliseconds. +This option is passed directly to s6-svscan.
+
+ +

Notes

+ + + + + diff --git a/src/supervision/s6-svscanboot.c b/src/supervision/s6-svscanboot.c index 8de924b..3ab6b8e 100644 --- a/src/supervision/s6-svscanboot.c +++ b/src/supervision/s6-svscanboot.c @@ -62,7 +62,7 @@ int main (int argc, char const *const *argv) { .so = 'L', .lo = "name-max", .i = GOLA_MAXLEN }, { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT }, } ; - unsigned int catchall_mode = 02700 ; + unsigned int catchall_mode = 02750 ; unsigned int fdconsole = 3 ; unsigned int fdnotif = 0 ; unsigned int servicesmax = 0 ; @@ -218,9 +218,9 @@ int main (int argc, char const *const *argv) if (fd_move(0, fd) == -1) strerr_diefusys(111, "fd_move ", "/dev/null", " to ", "stdin") ; if (wgola[GOLA_CONSOLE]) { - fd = open2("/dev/console", O_WRONLY) ; - if (fd == -1) strerr_diefusys(111, "open ", "/dev/console") ; - if (fd_move(fdconsole, fd) == -1) strerr_diefusys(111, "fd_move ", "/dev/console") ; + fd = open2(wgola[GOLA_CONSOLE], O_WRONLY) ; + if (fd == -1) strerr_diefusys(111, "open ", wgola[GOLA_CONSOLE]) ; + if (fd_move(fdconsole, fd) == -1) strerr_diefusys(111, "fd_move ", wgola[GOLA_CONSOLE]) ; } else if (fd_copy(fdconsole, 2) == -1) strerr_diefusys(111, "fd_copy ", "stderr") ; b.fd = open2(fn, O_RDONLY | O_NONBLOCK) ; @@ -230,7 +230,7 @@ int main (int argc, char const *const *argv) fd_close(b.fd) ; if (ndelay_off(fd) == -1) strerr_diefusys(111, "ndelay_off ", fn) ; if (fd_move(1, fd) == -1) strerr_diefusys(111, "fd_move ", fn, " to ", "stdout") ; - if (fd_copy(2, 1) == -1) strerr_diefusys(111, "copy ", "stdout", " to ", "stderr") ; + if (fd_copy(2, 1) == -1) strerr_diefusys(111, "fd_copy ", "stdout", " to ", "stderr") ; fmtc[uint_fmt(fmtc, fdconsole)] = 0 ; @@ -266,5 +266,6 @@ int main (int argc, char const *const *argv) newargv[m++] = 0 ; exec(newargv) ; - _exit(111) ; + if (fd_move(2, fdconsole) == -1) _exit(111) ; + strerr_diefusys(111, "exec ", newargv[0]) ; } -- cgit v1.3.1