Skip to content

Commit

Permalink
Merge pull request #81 from bgamari/master
Browse files Browse the repository at this point in the history
Don't close already closed pipes
  • Loading branch information
snoyberg authored Dec 13, 2016
2 parents 28946c6 + 9d68cb1 commit a71d831
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cbits/runProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ runInteractiveProcess (char *const args[],
if ((flags & RUN_PROCESS_IN_NEW_GROUP) != 0) {
setpgid(0, 0);
}

if ( childGroup) {
if ( setgid( *childGroup) != 0) {
// ERROR
Expand Down Expand Up @@ -240,9 +240,9 @@ runInteractiveProcess (char *const args[],
}
// XXX Not the pipe
for (i = 3; i < max_fd; i++) {
if (i != forkCommunicationFds[1]) {
close(i);
}
if (i != forkCommunicationFds[1]) {
close(i);
}
}
}

Expand Down Expand Up @@ -341,16 +341,16 @@ runInteractiveProcess (char *const args[],
waitpid(pid, NULL, 0);

if (fdStdIn == -1) {
close(fdStdInput[0]);
// Already closed fdStdInput[0] above
close(fdStdInput[1]);
}
if (fdStdOut == -1) {
close(fdStdOutput[0]);
close(fdStdOutput[1]);
// Already closed fdStdOutput[1] above
}
if (fdStdErr == -1) {
close(fdStdError[0]);
close(fdStdError[1]);
// Already closed fdStdError[1] above
}

pid = -1;
Expand Down

0 comments on commit a71d831

Please sign in to comment.