diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-05-19 11:52:33 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-05-19 11:52:33 +0000 |
commit | 4c43193fa3f7b49e68778d7345759f27c883072f (patch) | |
tree | 39cb30449a11ca154b70f3beb27efac33bbc836d /src | |
parent | 7017c7631eafee5b752904064a6d0daec94f32d9 (diff) | |
download | s6-4c43193fa3f7b49e68778d7345759f27c883072f.tar.xz |
Add the timeout-kill feature to s6-supervise. Prepare for version 2.5.1.0.
Diffstat (limited to 'src')
-rw-r--r-- | src/supervision/s6-supervise.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index a1a52f8..7527668 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -51,6 +51,7 @@ static tain_t deadline ; static tain_t dontrespawnbefore = TAIN_EPOCH ; static s6_svstatus_t status = S6_SVSTATUS_ZERO ; static state_t state = DOWN ; +static int flagdying = 0 ; static int cont = 1 ; static int notifyfd = -1 ; @@ -331,6 +332,7 @@ static int uplastup_z (void) status.wstat = (int)status.pid ; status.flagpaused = 0 ; status.flagready = 0 ; + flagdying = 0 ; tain_copynow(&status.stamp) ; if (notifyfd >= 0) { @@ -383,8 +385,16 @@ static void lastup_z (void) static void uptimeout (void) { - settimeout_infinite() ; - strerr_warnw1x("can't happen: timeout while the service is up!") ; + if (flagdying) + { + killk() ; + settimeout(5) ; + } + else + { + settimeout_infinite() ; + strerr_warnw1x("can't happen: timeout while the service is up!") ; + } } static void up_o (void) @@ -395,9 +405,18 @@ static void up_o (void) static void up_d (void) { + tain_t tto ; + unsigned int timeout ; status.flagwantup = 0 ; killt() ; killc() ; + if (!read_uint("timeout-kill", &timeout)) timeout = 0 ; + if (timeout && tain_from_millisecs(&tto, timeout)) + { + tain_add_g(&deadline, &tto) ; + flagdying = 1 ; + } + else settimeout_infinite() ; } static void up_u (void) |