aboutsummaryrefslogtreecommitdiffstats
path: root/scan.c
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2015-11-27 04:38:07 +0100
committerMarius Halden <marius.h@lden.org>2015-11-27 04:39:40 +0100
commit449c0694d6f9ff34bb0bd853a8da6312b3167f39 (patch)
tree26db5209f42861a68922035f84fd41d2c14da8e1 /scan.c
parente1939b04348e5467e8c85c6a1a05e68484101d41 (diff)
downloadsvcmon-449c0694d6f9ff34bb0bd853a8da6312b3167f39.tar.gz
svcmon-449c0694d6f9ff34bb0bd853a8da6312b3167f39.tar.bz2
svcmon-449c0694d6f9ff34bb0bd853a8da6312b3167f39.tar.xz
Wait no more than three seconds for reap_all()
Diffstat (limited to 'scan.c')
-rw-r--r--scan.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/scan.c b/scan.c
index fc6f877..1fe04fa 100644
--- a/scan.c
+++ b/scan.c
@@ -217,10 +217,18 @@ scan_svcdir(int dir_fd)
void
reap_all()
{
- int r;
+ int r, m = 0;
for (;;) {
- r = wait(NULL);
+ r = waitpid(-1, NULL, WNOHANG);
+
+ if (r == 0) {
+ m++;
+ if (m >= 3)
+ break;
+ sleep(1);
+ }
+
if (r != -1)
continue;
@@ -484,7 +492,7 @@ end:
reset_signals();
fprintf(stderr, "Waiting for children to exit\n");
- reap_all(); /* XXX: Maybe remove this for shorter shutdown? */
+ reap_all();
return 0;
}