diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-20 14:52:26 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-03-20 14:52:26 +0000 |
commit | 26c5fee82736e56cff3d114ff9d6e3969d1ce061 (patch) | |
tree | a43283438dc8d22b339cda86b0d80c58ef86bf4d /src/supervision | |
parent | 1747a0f5142f0c36a61b37786368f05bcb3060f3 (diff) | |
download | s6-26c5fee82736e56cff3d114ff9d6e3969d1ce061.tar.xz |
Add death tally support to s6-supervise, throttling support to s6_svstatus_t
Diffstat (limited to 'src/supervision')
-rw-r--r-- | src/supervision/s6-supervise.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index 71f247e..00c2358 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -332,6 +332,7 @@ static int uplastup_z (void) status.wstat = (int)status.pid ; status.flagpaused = 0 ; status.flagready = 0 ; + status.flagthrottled = 0 ; flagdying = 0 ; tain_copynow(&status.stamp) ; if (notifyfd >= 0) @@ -339,6 +340,27 @@ static int uplastup_z (void) fd_close(notifyfd) ; notifyfd = -1 ; } + + { + unsigned int n ; + if (!read_uint("max-death-tally", &n)) n = 20 ; + if (n > S6_MAX_DEATH_TALLY) n = S6_MAX_DEATH_TALLY ; + if (n) + { + s6_dtally_t tab[n+1] ; + ssize_t m = s6_dtally_read(".", tab, n) ; + if (m < 0) strerr_warnwu2sys("read ", S6_DTALLY_FILENAME) ; + else + { + tab[m].stamp = status.stamp ; + tab[m].sig = WIFSIGNALED(status.wstat) ? WTERMSIG(status.wstat) : 0 ; + tab[m].exitcode = WIFSIGNALED(status.wstat) ? 128 + WTERMSIG(status.wstat) : WEXITSTATUS(status.wstat) ; + if (m >= n ? s6_dtally_write(".", tab+1, n) : s6_dtally_write(".", tab, m+1)) + strerr_warnwu2sys("write ", S6_DTALLY_FILENAME) ; + } + } + } + status.pid = fork() ; if (status.pid < 0) { @@ -617,6 +639,11 @@ int main (int argc, char const *const *argv) if (!ftrigw_clean(S6_SUPERVISE_EVENTDIR)) strerr_warnwu2sys("ftrigw_clean ", S6_SUPERVISE_EVENTDIR) ; + { + int fd = open_trunc(S6_DTALLY_FILENAME) ; + if (fd < 0) strerr_diefu2sys(111, "truncate ", S6_DTALLY_FILENAME) ; + fd_close(fd) ; + } if (access("down", F_OK) == 0) status.flagwantup = 0 ; else if (errno != ENOENT) |