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:
cptpcrd 2023-05-21 12:15:49 -04:00
parent 6163be687d
commit 5cbbfd5c8a

View File

@ -82,6 +82,8 @@ inline FILE* open(const std::string& cmd, int& pid) {
if (child_pid < 0) { if (child_pid < 0) {
spdlog::error("Unable to exec cmd {}, error {}", cmd.c_str(), strerror(errno)); spdlog::error("Unable to exec cmd {}, error {}", cmd.c_str(), strerror(errno));
::close(fd[0]);
::close(fd[1]);
return nullptr; return nullptr;
} }