Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't close already closed pipes #81

Merged
merged 2 commits into from
Dec 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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