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 /src/runit.c | |
parent | c826ec66accb8090816b11cf8168bb46c4c6358e (diff) | |
download | runit-e227125c69befc2e72803e133d3d1c8baf3410fa.tar.gz runit-e227125c69befc2e72803e133d3d1c8baf3410fa.tar.xz runit-e227125c69befc2e72803e133d3d1c8baf3410fa.zip |
runit.c: speed up collecting zombies.
Diffstat (limited to 'src/runit.c')
-rw-r--r-- | src/runit.c | 11 |
1 files changed, 8 insertions, 3 deletions
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; |