s6

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

commit 8fd7d96ea5a4dd6be8a1c7d67a740df8b5148a79
parent 5f247199e897e2d79d1a31bfb53e2fdc943a4bde
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Tue,  1 Sep 2015 00:18:50 +0000

 s6-svscan bugfix: remove inactive dead services after the next scan

Diffstat:
Msrc/supervision/s6-svscan.c | 21++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c @@ -240,7 +240,7 @@ static void reap (void) } else if (services[i].p[0] == -2) wantscan = 1 ; } - if (!services[i].pid[0] && !services[i].pid[1]) + if (!services[i].pid[0] && (!services[i].flaglog || !services[i].pid[1])) services[i] = services[--n] ; } } @@ -376,6 +376,7 @@ static void check (char const *name) static void scan (void) { + unsigned int i = 0 ; DIR *dir ; if (!wantscan) return ; wantscan = 0 ; @@ -386,10 +387,7 @@ static void scan (void) retrydirlater() ; return ; } - { - register unsigned int i = 0 ; - for (; i < n ; i++) services[i].flagactive = 0 ; - } + for (; i < n ; i++) services[i].flagactive = 0 ; for (;;) { direntry *d ; @@ -404,6 +402,19 @@ static void scan (void) retrydirlater() ; } dir_close(dir) ; + for (i = 0 ; i < n ; i++) if (!services[i].flagactive && !services[i].pid[0]) + { + if (services[i].flaglog) + { + if (services[i].pid[1]) continue ; + if (services[i].p[0] >= 0) + { + fd_close(services[i].p[1]) ; services[i].p[1] = -1 ; + fd_close(services[i].p[0]) ; services[i].p[0] = -1 ; + } + } + services[i] = services[--n] ; + } }