diff options
author | Gerrit Pape <pape@smarden.org> | 2007-09-13 13:35:09 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2007-09-13 13:38:58 +0000 |
commit | e227125c69befc2e72803e133d3d1c8baf3410fa (patch) | |
tree | a0a34fae7b5c98093481e16d79257552f9aaeaf0 | |
parent | c826ec66accb8090816b11cf8168bb46c4c6358e (diff) | |
download | runit-e227125c69befc2e72803e133d3d1c8baf3410fa.tar.gz runit-e227125c69befc2e72803e133d3d1c8baf3410fa.tar.xz runit-e227125c69befc2e72803e133d3d1c8baf3410fa.zip |
runit.c: speed up collecting zombies.
-rw-r--r-- | package/CHANGES | 1 | ||||
-rw-r--r-- | src/runit.c | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/package/CHANGES b/package/CHANGES index f30fee5..cfa407f 100644 --- a/package/CHANGES +++ b/package/CHANGES @@ -14,6 +14,7 @@ * uw_tmp.h1: fallback to UTMP_FILE if _PATH_UTMP is not defined as seen on AIX 5.2 ML1, AIX 5.3 ML5 (thx Daniel Clark). * sv.c: fix race on check for down if pid is 0 and state is run or finish. + * runit.c: speed up collecting zombies. 1.7.2 Tue, 21 Nov 2006 15:13:47 +0000 diff --git a/src/runit.c b/src/runit.c index f7d6522..77ee93f 100644 --- a/src/runit.c +++ b/src/runit.c @@ -157,8 +157,13 @@ int main (int argc, const char * const *argv, char * const *envp) { sig_block(sig_child); sig_block(sig_int); - read(selfpipe[0], &ch, 1); - child =wait_nohang(&wstat); + while (read(selfpipe[0], &ch, 1) == 1) {} + while ((child =wait_nohang(&wstat)) > 0) + if (child == pid) break; + if (child == -1) { + strerr_warn2(WARNING, "wait_nohang, pausing: ", &strerr_sys); + sleep(5); + } /* reget stderr */ if ((ttyfd =open_write("/dev/console")) != -1) { @@ -194,7 +199,7 @@ int main (int argc, const char * const *argv, char * const *envp) { strerr_warn3(INFO, "leave stage: ", stage[st], 0); break; } - if (child > 0) { + if (child != 0) { /* collect terminated children */ write(selfpipe[1], "", 1); continue; |