From 8fd7d96ea5a4dd6be8a1c7d67a740df8b5148a79 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 1 Sep 2015 00:18:50 +0000 Subject: s6-svscan bugfix: remove inactive dead services after the next scan --- src/supervision/s6-svscan.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/supervision') diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c index 7ab959c..c66b18f 100644 --- 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] ; + } } -- cgit v1.2.3