]> granicus.if.org Git - sudo/commitdiff
In handle_signals(), restart the read() on EINTR to make sure we keep up
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Mar 2011 15:55:54 +0000 (11:55 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Mar 2011 15:55:54 +0000 (11:55 -0400)
with the signal pipe.  Don't return -1 on EAGAIN, it just means we have
emptied the pipe.

--HG--
branch : 1.7

exec.c

diff --git a/exec.c b/exec.c
index af54d30adc93167a7322bfb1704b90e8ff95636c..b41940a5f8c19f80193fd5faf2e5a52c9c137f59 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -359,8 +359,6 @@ sudo_execve(path, argv, envp, uid, cstat, dowait, bgmode)
                goto done;
            }
            if (n == -1) {
-               if (errno == EAGAIN || errno == EINTR)
-                   continue;
                /* Error reading signal_pipe[0], should not happen. */
                break;
            }
@@ -445,7 +443,7 @@ done:
 
 /*
  * Read signals on fd written to by handler().
- * Returns -1 on error (possibly non-fatal), 0 on child exit, else 1.
+ * Returns -1 on error, 0 on child exit, else 1.
  */
 static int
 handle_signals(fd, child, cstat)
@@ -465,10 +463,14 @@ handle_signals(fd, child, cstat)
            /* It should not be possible to get EOF but just in case. */
            if (nread == 0)
                errno = ECONNRESET;
-           if (errno != EINTR && errno != EAGAIN) {
-               cstat->type = CMD_ERRNO;
-               cstat->val = errno;
-           }
+           /* Restart if interrupted by signal so the pipe doesn't fill. */
+           if (errno == EINTR)
+               continue;
+           /* If pipe is empty, we are done. */
+           if (errno == EAGAIN)
+               break;
+           cstat->type = CMD_ERRNO;
+           cstat->val = errno;
            return -1;
        }
        if (signo == SIGCHLD) {