diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-02 12:09:48 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-02 12:09:48 +0000 |
commit | 1747a0f5142f0c36a61b37786368f05bcb3060f3 (patch) | |
tree | 513ca73e83f6d9bdc39784d3c0f085c418f24720 | |
parent | fa342a6615c39c1760a41011f713f696d1eb5c33 (diff) | |
download | s6-1747a0f5142f0c36a61b37786368f05bcb3060f3.tar.xz |
Make s6-svwait et al. exit instead of hang if s6-supervise dies
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | doc/index.html | 2 | ||||
-rw-r--r-- | doc/s6-svlisten.html | 1 | ||||
-rw-r--r-- | doc/s6-svlisten1.html | 1 | ||||
-rw-r--r-- | doc/s6-svwait.html | 1 | ||||
-rw-r--r-- | doc/upgrade.html | 2 | ||||
-rw-r--r-- | src/supervision/s6-svlisten.c | 3 | ||||
-rw-r--r-- | src/supervision/s6-svlisten1.c | 3 | ||||
-rw-r--r-- | src/supervision/s6-svwait.c | 3 | ||||
-rw-r--r-- | src/supervision/s6_svlisten_loop.c | 5 |
11 files changed, 16 insertions, 8 deletions
@@ -6,7 +6,7 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.6.3.2 or later: http://skarnet.org/software/skalibs/ + - skalibs version 2.6.4.0 or later: http://skarnet.org/software/skalibs/ - execline version 2.3.0.4 or later: http://skarnet.org/software/execline/ This software will run on any operating system that implements @@ -4,6 +4,7 @@ In 2.7.0.1 ---------- - Bugfixes. + - s6-svwait et al. now exit 102 instead of hanging if s6-supervise dies. In 2.7.0.0 diff --git a/doc/index.html b/doc/index.html index 7a00b7c..cbc24ed 100644 --- a/doc/index.html +++ b/doc/index.html @@ -83,7 +83,7 @@ with s6</a> </li> <li> A POSIX-compliant system with a standard C development environment </li> <li> GNU make, version 3.81 or later </li> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version -2.6.3.2 or later. It's a build-time requirement. It's also a run-time +2.6.4.0 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the skalibs library. </li> <li> <a href="//skarnet.org/software/execline/">execline</a> version diff --git a/doc/s6-svlisten.html b/doc/s6-svlisten.html index 30e4018..8fdbc88 100644 --- a/doc/s6-svlisten.html +++ b/doc/s6-svlisten.html @@ -60,6 +60,7 @@ initial state of all the monitored services. </li> <li> 0: success, the wanted state has been reached </li> <li> 99: timed out </li> <li> 100: wrong usage </li> + <li> 102: the <a href="s6-supervise.html">s6-supervise</a> process monitoring the service died </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> diff --git a/doc/s6-svlisten1.html b/doc/s6-svlisten1.html index cfe48e7..91c8625 100644 --- a/doc/s6-svlisten1.html +++ b/doc/s6-svlisten1.html @@ -49,6 +49,7 @@ initial state of the service. </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> 102: the <a href="s6-supervise.html">s6-supervise</a> process monitoring the service died </li> <li> 111: system call failed </li> </ul> diff --git a/doc/s6-svwait.html b/doc/s6-svwait.html index 38fec11..fb377b9 100644 --- a/doc/s6-svwait.html +++ b/doc/s6-svwait.html @@ -44,6 +44,7 @@ happen. <li> 0: success, the wanted state has been reached </li> <li> 99: timed out </li> <li> 100: wrong usage </li> + <li> 102: the <a href="s6-supervise.html">s6-supervise</a> process monitoring the service died </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> diff --git a/doc/upgrade.html b/doc/upgrade.html index 5799845..c37ad15 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -21,7 +21,7 @@ <h2> in 2.7.0.1 </h2> <ul> - <li> skalibs dependency bumped to 2.6.3.2. </li> + <li> skalibs dependency bumped to 2.6.4.0. </li> </ul> <h2> in 2.7.0.0 </h2> diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c index 7e1b930..e44ba87 100644 --- a/src/supervision/s6-svlisten.c +++ b/src/supervision/s6-svlisten.c @@ -72,7 +72,8 @@ int main (int argc, char const **argv, char const *const *envp) if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + 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") ; + if (e < 0) strerr_dief1x(102, "supervisor died") ; + else if (e > 0) strerr_dief1x(e, "some services reported permanent failure") ; } return 0 ; } diff --git a/src/supervision/s6-svlisten1.c b/src/supervision/s6-svlisten1.c index 62afc15..69d8ac7 100644 --- a/src/supervision/s6-svlisten1.c +++ b/src/supervision/s6-svlisten1.c @@ -53,6 +53,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!pid) strerr_diefu2sys(111, "spawn ", argv[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") ; + if (e < 0) strerr_dief1x(102, "supervisor died") ; + else if (e > 0) strerr_dief2x(1, argv[0], " failed permanently: the finish script exited 125") ; return 0 ; } diff --git a/src/supervision/s6-svwait.c b/src/supervision/s6-svwait.c index 28d1c3d..f2bd34c 100644 --- a/src/supervision/s6-svwait.c +++ b/src/supervision/s6-svwait.c @@ -52,7 +52,8 @@ int main (int argc, char const *const *argv) unsigned char readystate[bitarray_div8(argc)] ; s6_svlisten_init(argc, argv, &foo, ids, upstate, readystate, &deadline) ; e = s6_svlisten_loop(&foo, wantup, wantready, or, &deadline, -1, 0) ; - if (e) strerr_dief1x(e, "some services reported permanent failure") ; + if (e < 0) strerr_dief1x(102, "supervisor died") ; + else if (e > 0) strerr_dief1x(e, "some services reported permanent failure") ; } return 0 ; } diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c index c98fe83..8c6500c 100644 --- a/src/supervision/s6_svlisten_loop.c +++ b/src/supervision/s6_svlisten_loop.c @@ -27,7 +27,7 @@ void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, ui memcpy(s, argv[i], len) ; s[len] = '/' ; memcpy(s + len + 1, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; - foo->ids[i] = ftrigr_subscribe_g(&foo->a, s, "[DuUdO]", FTRIGR_REPEAT, deadline) ; + foo->ids[i] = ftrigr_subscribe_g(&foo->a, s, "[DuUdOx]", FTRIGR_REPEAT, deadline) ; if (!foo->ids[i]) strerr_diefu2sys(111, "subscribe to events for ", argv[i]) ; if (!s6_svstatus_read(argv[i], &status)) strerr_diefu1sys(111, "s6_svstatus_read") ; bitarray_poke(foo->upstate, i, status.pid && !status.flagfinishing) ; @@ -72,7 +72,8 @@ int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tai size_t j = 0 ; for (; j < sa.len ; j++) { - if (sa.s[j] == 'O') + if (sa.s[j] == 'x') return -1 ; + else if (sa.s[j] == 'O') { if (wantup) { |