From: Todd C. Miller Date: Wed, 16 Mar 2011 15:55:54 +0000 (-0400) Subject: In handle_signals(), restart the read() on EINTR to make sure we keep up X-Git-Tag: SUDO_1_7_6~49 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7924b8d0697396800e182c4603e3cb9562a86201;p=sudo In handle_signals(), restart the read() on EINTR to make sure we keep up with the signal pipe. Don't return -1 on EAGAIN, it just means we have emptied the pipe. --HG-- branch : 1.7 --- diff --git a/exec.c b/exec.c index af54d30ad..b41940a5f 100644 --- 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) {