s6

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

commit ded312bcc44704ea16fdfe9fb9f2b46bfd0f537b
parent 9a669c4b3973118dfcce2a2b1fb4babd0aaa6af7
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 27 Mar 2017 14:05:21 +0000

 Clarify permanent failure API for s6-svwait -r and friends; update doc

Diffstat:
Mdoc/s6-svlisten.html | 13++++++++++++-
Mdoc/s6-svlisten1.html | 12+++++++++++-
Mdoc/s6-svwait.html | 13++++++++++++-
Mdoc/upgrade.html | 13+++++++------
Msrc/supervision/s6-svlisten.c | 19+++++++------------
Msrc/supervision/s6-svlisten1.c | 19+++++++------------
Msrc/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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 {