Plug a file descriptor leak if fork() fails

(Not that we really care if that happens ;-) but it's good to be correct.)
This commit is contained in:
Andrew Ayer
2014-03-28 13:54:18 -07:00
parent b2bdc11330
commit 2b5e4a752e

View File

@@ -112,7 +112,10 @@ int exec_command (const char* command, std::ostream& output)
}
pid_t child = fork();
if (child == -1) {
throw System_error("fork", "", errno);
int fork_errno = errno;
close(pipefd[0]);
close(pipefd[1]);
throw System_error("fork", "", fork_errno);
}
if (child == 0) {
close(pipefd[0]);