runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 32887db7d20302b2924bf45a9b1efb7ce45aa7aa
parent bdd6e8ca2ae0437f9b05ff2d8863808032e103e6
Author: Gerrit Pape <pape@smarden.org>
Date:   Thu, 13 Sep 2007 13:35:09 +0000

runit.c: speed up collecting zombies.

Diffstat:
Mpackage/CHANGES | 1+
Msrc/runit.c | 11++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git 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 @@ -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;