]> granicus.if.org Git - sudo/commitdiff
Fix waitpid() loop termination condition.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 9 Aug 2010 10:34:55 +0000 (06:34 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 9 Aug 2010 10:34:55 +0000 (06:34 -0400)
--HG--
branch : 1.7

exec.c

diff --git a/exec.c b/exec.c
index 93316a0012b11f71e2f0bc7502ead5b4faad9c7e..a15403cc20a957a8b3265e53bdbe3d22f2812547 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -260,21 +260,22 @@ sudo_execve(path, argv, envp, uid, cstat, dowait, bgmode)
 #else
                pid = wait(&status);
 #endif
-               if (pid == child) {
-                   if (!log_io) {
-                       if (WIFSTOPPED(status)) {
-                           /* Child may not have privs to suspend us itself. */
-                           kill(getpid(), WSTOPSIG(status));
-                       } else {
-                           /* Child has exited, we are done. */
-                           cstat->type = CMD_WSTATUS;
-                           cstat->val = status;
-                           return 0;
-                       }
+           } while (pid == -1 && errno == EINTR);
+           if (pid == child) {
+               /* If not logging I/O and child has exited we are done. */
+               if (!log_io) {
+                   if (WIFSTOPPED(status)) {
+                       /* Child may not have privs to suspend us itself. */
+                       kill(getpid(), WSTOPSIG(status));
+                   } else {
+                       /* Child has exited, we are done. */
+                       cstat->type = CMD_WSTATUS;
+                       cstat->val = status;
+                       return 0;
                    }
-                   /* Else we get ECONNRESET on sv[0] if child dies. */
                }
-           } while (pid != -1 || errno == EINTR);
+               /* Else we get ECONNRESET on sv[0] if child dies. */
+           }
        }
 
        zero_bytes(fdsw, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));