s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 803eb463a54c54bb623176573c51f382f52ee9a9
parent eba790dff930c232d6b5266fdfda0b1231167609
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sun, 25 Jun 2023 18:16:43 +0000

 Loosen nonzero servicedirs requirement on s6-svwait/s6-svlisten

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Mdoc/s6-svlisten.html | 2++
Mdoc/s6-svwait.html | 2+-
Msrc/supervision/s6-svlisten.c | 4+++-
Msrc/supervision/s6-svwait.c | 2+-
4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/doc/s6-svlisten.html b/doc/s6-svlisten.html @@ -52,6 +52,8 @@ their state changes. </li> <li> It spawns <em>prog...</em> as a child right after getting the initial state of all the monitored services. </li> <li> It then blocks until the wanted state happens. </li> + <li> If no service directories are listed (the block is empty), then +instead of doing all that, it immediately execs into <em>prog...</em>. </ul> <h2> Exit codes </h2> diff --git a/doc/s6-svwait.html b/doc/s6-svwait.html @@ -35,7 +35,7 @@ s6-svwait only waits for notifications; it never polls. <p> s6-svwait monitors one or more <a href="servicedir.html">service directories</a> given as its arguments, waiting for a state (ready, up or down) to -happen. +happen. If no service directories are listed, it immediately exits 0. </p> <h2> Exit codes </h2> diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c @@ -9,6 +9,7 @@ #include <skalibs/strerr.h> #include <skalibs/djbunix.h> #include <skalibs/selfpipe.h> +#include <skalibs/exec.h> #include <s6/compat.h> #include "s6-svlisten.h" @@ -49,8 +50,9 @@ int main (int argc, char const **argv, char const *const *envp) } if (argc < 3) dieusage() ; argc1 = s6_el_semicolon(argv) ; - if (!argc1 || argc == argc1 + 1) dieusage() ; + if (argc == argc1 + 1) dieusage() ; if (argc1 >= argc) strerr_dief1x(100, "unterminated servicedir block") ; + if (!argc1) xexec(argv + argc1 + 1) ; if (wantup == 2 && or) { or = 0 ; diff --git a/src/supervision/s6-svwait.c b/src/supervision/s6-svwait.c @@ -45,7 +45,7 @@ int main (int argc, char const *const *argv) argc -= l.ind ; argv += l.ind ; if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; } - if (!argc) dieusage() ; + if (!argc) return 0 ; tain_now_set_stopwatch_g() ; tain_add_g(&deadline, &deadline) ;