Close pipe if fork() fails when spawning processes

Prevents potential file descriptor leakage, albeit in a bit of an edge
case.
pull/2182/head
cptpcrd 2023-05-21 12:15:49 -04:00
parent 6163be687d
commit 5cbbfd5c8a
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}