diff options
-rw-r--r-- | doc/s6-svlisten.html | 13 | ||||
-rw-r--r-- | doc/s6-svlisten1.html | 12 | ||||
-rw-r--r-- | doc/s6-svwait.html | 13 | ||||
-rw-r--r-- | doc/upgrade.html | 13 | ||||
-rw-r--r-- | src/supervision/s6-svlisten.c | 19 | ||||
-rw-r--r-- | src/supervision/s6-svlisten1.c | 19 | ||||
-rw-r--r-- | src/supervision/s6_svlisten_loop.c | 9 |
7 files changed, 62 insertions, 36 deletions
diff --git a/doc/s6-svlisten.html b/doc/s6-svlisten.html index 0a3f427..192b351 100644 --- a/doc/s6-svlisten.html +++ b/doc/s6-svlisten.html @@ -51,7 +51,18 @@ directories</a> given as arguments in the first block and monitor 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, then exits 0. </li> + <li> It then blocks until the wanted state happens. </li> +</ul> + +<h2> Exit codes </h2> + +<ul> + <li> 0: success, the wanted state has been reached </li> + <li> 99: timed out </li> + <li> 100: wrong usage </li> + <li> 111: system call failed </li> + <li> <em>n</em>: services were expected to come up, but <em>n</em> of them +reported permanent failure </li> </ul> <h2> Options </h2> diff --git a/doc/s6-svlisten1.html b/doc/s6-svlisten1.html index 762c3ff..902e0be 100644 --- a/doc/s6-svlisten1.html +++ b/doc/s6-svlisten1.html @@ -39,7 +39,17 @@ supervised service, and blocks until said service goes up, or down. state changes. </li> <li> It spawns <em>prog...</em> as a child right after getting the initial state of the service. </li> - <li> It then blocks until the wanted state happens, then exits 0. </li> + <li> It then blocks until the wanted state happens. </li> +</ul> + +<h2> Exit codes </h2> + +<ul> + <li> 0: success, the wanted state has been reached </li> + <li> 1: the service was supposed to go up, but reported permanent failure </li> + <li> 99: timed out </li> + <li> 100: wrong usage </li> + <li> 111: system call failed </li> </ul> <h2> Options </h2> diff --git a/doc/s6-svwait.html b/doc/s6-svwait.html index 681dd8f..36b1835 100644 --- a/doc/s6-svwait.html +++ b/doc/s6-svwait.html @@ -35,9 +35,20 @@ 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. It exits 0 when the wanted condition becomes true. +happen. </p> +<h2> Exit codes </h2> + +<ul> + <li> 0: success, the wanted state has been reached </li> + <li> 99: timed out </li> + <li> 100: wrong usage </li> + <li> 111: system call failed </li> + <li> <em>n</em>: services were expected to come up, but <em>n</em> of them +reported permanent failure </li> +</ul> + <h2> Options </h2> <ul> diff --git a/doc/upgrade.html b/doc/upgrade.html index 3a4c104..b6ed251 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -23,12 +23,13 @@ <ul> <li> skalibs dependency bumped to 2.5.0.0. </li> <li> execline dependency bumped to 2.3.0.0. </li> -</ul> - -<h2> in 2.4.1.0 </h2> - -<ul> - <li> skalibs dependency bumped to 2.4.0.1. </li> + <li> Services can now report permanent failure by having <tt>./finish</tt> +exit 125. </li> + <li> <a href="s6-svwait.html">s6-svwait</a>, + <a href="s6-svlisten.html">s6-svlisten</a> and + <a href="s6-svlisten1.html">s6-svlisten1</a> now exit 99 +when they time out. They exit <em>n</em> when there are <em>n</em> +services reporting permanent failure. </li> </ul> <h2> in 2.4.0.0 </h2> diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c index d15557a..7e1b930 100644 --- a/src/supervision/s6-svlisten.c +++ b/src/supervision/s6-svlisten.c @@ -30,12 +30,12 @@ int main (int argc, char const **argv, char const *const *envp) if (opt == -1) break ; switch (opt) { - case 'u' : wantup = 1 ; wantready = 0 ; break ; - case 'U' : wantup = 1 ; wantready = 1 ; break ; - case 'd' : wantup = 0 ; wantready = 0 ; break ; - case 'D' : wantup = 0 ; wantready = 1 ; break ; - case 'r' : wantrestart = 1 ; wantready = 0 ; break ; - case 'R' : wantrestart = 1 ; wantready = 1 ; break ; + case 'u' : wantup = 1 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'U' : wantup = 1 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'd' : wantup = 0 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'D' : wantup = 0 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'r' : wantup = 1 ; wantrestart = 1 ; wantready = 0 ; break ; + case 'R' : wantup = 1 ; wantrestart = 1 ; wantready = 1 ; break ; case 'a' : or = 0 ; break ; case 'o' : or = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; @@ -70,12 +70,7 @@ int main (int argc, char const **argv, char const *const *envp) s6_svlisten_init(argc1, argv, &foo, ids, upstate, readystate, &deadline) ; pid = child_spawn0(argv[argc1 + 1], argv + argc1 + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + 1]) ; - if (wantrestart) - { - e = s6_svlisten_loop(&foo, 0, 1, or, &deadline, spfd, &s6_svlisten_signal_handler) ; - if (e) strerr_dief1x(e, "some services reported permanent failure") ; - wantup = 1 ; - } + if (wantrestart) s6_svlisten_loop(&foo, 0, 1, or, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, or, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e) strerr_dief1x(e, "some services reported permanent failure") ; } diff --git a/src/supervision/s6-svlisten1.c b/src/supervision/s6-svlisten1.c index af9959a..62afc15 100644 --- a/src/supervision/s6-svlisten1.c +++ b/src/supervision/s6-svlisten1.c @@ -31,12 +31,12 @@ int main (int argc, char const *const *argv, char const *const *envp) if (opt == -1) break ; switch (opt) { - case 'u' : wantup = 1 ; wantready = 0 ; break ; - case 'U' : wantup = 1 ; wantready = 1 ; break ; - case 'd' : wantup = 0 ; wantready = 0 ; break ; - case 'D' : wantup = 0 ; wantready = 1 ; break ; - case 'r' : wantrestart = 1 ; wantready = 0 ; break ; - case 'R' : wantrestart = 1 ; wantready = 1 ; break ; + case 'u' : wantup = 1 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'U' : wantup = 1 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'd' : wantup = 0 ; wantrestart = 0 ; wantready = 0 ; break ; + case 'D' : wantup = 0 ; wantrestart = 0 ; wantready = 1 ; break ; + case 'r' : wantup = 1 ; wantrestart = 1 ; wantready = 0 ; break ; + case 'R' : wantup = 1 ; wantrestart = 1 ; wantready = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; default : dieusage() ; } @@ -51,12 +51,7 @@ int main (int argc, char const *const *argv, char const *const *envp) s6_svlisten_init(1, argv, &foo, &id, &upstate, &readystate, &deadline) ; pid = child_spawn0(argv[1], argv + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[1]) ; - if (wantrestart) - { - int e = s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; - if (e) strerr_dief2x(1, argv[0], " failed permanently: the finish script exited 125") ; - wantup = 1 ; - } + if (wantrestart) s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e) strerr_dief2x(1, argv[0], " failed permanently: the finish script exited 125") ; return 0 ; diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c index d2e776a..5c55c81 100644 --- a/src/supervision/s6_svlisten_loop.c +++ b/src/supervision/s6_svlisten_loop.c @@ -67,9 +67,12 @@ int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tai { if (what == 'O') { - bitarray_poke(foo->upstate, i, wantup) ; - bitarray_poke(foo->readystate, i, wantready) ; - e++ ; + if (wantup) + { + bitarray_poke(foo->upstate, i, wantup) ; + bitarray_poke(foo->readystate, i, wantready) ; + e++ ; + } } else { |