Close pipe if fork() fails when spawning processes
Prevents potential file descriptor leakage, albeit in a bit of an edge case.
This commit is contained in:
parent
6163be687d
commit
5cbbfd5c8a
|
@ -82,6 +82,8 @@ inline FILE* open(const std::string& cmd, int& pid) {
|
|||
|
||||
if (child_pid < 0) {
|
||||
spdlog::error("Unable to exec cmd {}, error {}", cmd.c_str(), strerror(errno));
|
||||
::close(fd[0]);
|
||||
::close(fd[1]);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue