From: Timo Sirainen Date: Wed, 25 Jun 2003 16:39:06 +0000 (+0300) Subject: Call waitpid() until no processes are left, instead of one per second. X-Git-Tag: 1.1.alpha1~4530 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1781e057a60ae780ced3bf2f249d951419568e8e;p=thirdparty%2Fdovecot%2Fcore.git Call waitpid() until no processes are left, instead of one per second. --HG-- branch : HEAD --- diff --git a/src/auth/passdb-pam.c b/src/auth/passdb-pam.c index 0dd50a8706..1dd43941be 100644 --- a/src/auth/passdb-pam.c +++ b/src/auth/passdb-pam.c @@ -301,22 +301,20 @@ static void wait_timeout(void *context __attr_unused__) pid_t pid; /* FIXME: if we ever do some other kind of forking, this needs fixing */ - pid = waitpid(-1, &status, WNOHANG); - if (pid == 0) - return; - - if (pid == -1) { - if (errno == ECHILD) { - timeout_remove(to_wait); - to_wait = NULL; - } else if (errno != EINTR) - i_error("waitpid() failed: %m"); - return; - } + while ((pid = waitpid(-1, &status, WNOHANG)) != 0) { + if (pid == -1) { + if (errno == ECHILD) { + timeout_remove(to_wait); + to_wait = NULL; + } else if (errno != EINTR) + i_error("waitpid() failed: %m"); + return; + } - if (WIFSIGNALED(status)) { - i_error("PAM: Child %s died with signal %d", - dec2str(pid), WTERMSIG(status)); + if (WIFSIGNALED(status)) { + i_error("PAM: Child %s died with signal %d", + dec2str(pid), WTERMSIG(status)); + } } }