Avoid a potential race condition if SIGCHLD is received immediately
before we call select().
This commit is contained in:
@@ -766,6 +766,8 @@ script_execve(struct command_details *details, char *argv[], char *envp[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recvsig[SIGCHLD])
|
||||||
|
continue;
|
||||||
nready = select(maxfd + 1, fdsr, fdsw, NULL, NULL);
|
nready = select(maxfd + 1, fdsr, fdsw, NULL, NULL);
|
||||||
if (nready == -1) {
|
if (nready == -1) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@@ -1050,7 +1052,7 @@ script_child(const char *path, char *argv[], char *envp[], int backchannel, int
|
|||||||
zero_bytes(&cstat, sizeof(cstat));
|
zero_bytes(&cstat, sizeof(cstat));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* Read child status */
|
/* Read child status */
|
||||||
while (recvsig[SIGCHLD]) {
|
if (recvsig[SIGCHLD]) {
|
||||||
recvsig[SIGCHLD] = FALSE;
|
recvsig[SIGCHLD] = FALSE;
|
||||||
/* read child status and relay to parent */
|
/* read child status and relay to parent */
|
||||||
do {
|
do {
|
||||||
@@ -1087,6 +1089,9 @@ script_child(const char *path, char *argv[], char *envp[], int backchannel, int
|
|||||||
if (errpipe[0] != -1)
|
if (errpipe[0] != -1)
|
||||||
FD_SET(errpipe[0], fdsr);
|
FD_SET(errpipe[0], fdsr);
|
||||||
maxfd = MAX(errpipe[0], backchannel);
|
maxfd = MAX(errpipe[0], backchannel);
|
||||||
|
|
||||||
|
if (recvsig[SIGCHLD])
|
||||||
|
continue;
|
||||||
n = select(maxfd + 1, fdsr, NULL, NULL, NULL);
|
n = select(maxfd + 1, fdsr, NULL, NULL, NULL);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
|
Reference in New Issue
Block a user