]> granicus.if.org Git - sudo/commitdiff
Also exit waitpid() loop when pid == 0. Fixes a problem where the sudo
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 9 Jun 2003 20:07:56 +0000 (20:07 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 9 Jun 2003 20:07:56 +0000 (20:07 +0000)
process would spin eating up CPU until sendmail finished when it has
to send mail.

logging.c

index b16c507bf37728621fc46604b7947da3718ff866..8b48caad833123c27fdc3174c2753757351add46 100644 (file)
--- 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