From: Todd C. Miller Date: Mon, 9 Jun 2003 20:07:56 +0000 (+0000) Subject: Also exit waitpid() loop when pid == 0. Fixes a problem where the sudo X-Git-Tag: SUDO_1_6_8~306 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27ad285a03f0780f29796da7f38f14c6450d1f91;p=sudo Also exit waitpid() loop when pid == 0. Fixes a problem where the sudo process would spin eating up CPU until sendmail finished when it has to send mail. --- diff --git a/logging.c b/logging.c index b16c507bf..8b48caad8 100644 --- a/logging.c +++ b/logging.c @@ -592,10 +592,12 @@ reapchild(sig) int sig; { int status, serrno = errno; - #ifdef sudo_waitpid - while (sudo_waitpid(-1, &status, WNOHANG) != -1 || errno == EINTR) - ; + pid_t pid; + + do { + pid = sudo_waitpid(-1, &status, WNOHANG); + } while (pid != 0 && (pid != -1 || errno == EINTR)); #else (void) wait(&status); #endif