Skip to content

Commit 30a8681

Browse files
Sjorsryanofsky
andcommitted
SpawnProcess: avoid fd leak on close failure
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
1 parent 14e926a commit 30a8681

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/mp/util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ int SpawnProcess(int& pid, FdToArgsFn&& fd_to_args)
128128
}
129129
// Parent process closes the descriptor for socket 0, child closes the descriptor for socket 1.
130130
if (close(fds[pid ? 0 : 1]) != 0) {
131+
if (pid) (void)close(fds[1]);
131132
throw std::system_error(errno, std::system_category(), "close");
132133
}
133134
if (!pid) {

0 commit comments

Comments
 (0)