Close fds explicitly

This commit is contained in:
Kovid Goyal
2024-09-28 12:40:42 +05:30
parent ced282c06c
commit 6131f4cba7

View File

@@ -136,7 +136,10 @@ spawn(PyObject *self UNUSED, PyObject *args) {
int fd = PyLong_AsLong(pfd);
if (fd > -1) {
if (fd == min_closed_fd) min_closed_fd++;
else if (safe_dup2(fd, min_closed_fd++) == -1) exit_on_err("dup2() failed for forwarded fd 1");
else {
if (safe_dup2(fd, min_closed_fd++) == -1) exit_on_err("dup2() failed for forwarded fd 1");
safe_close(fd, __FILE__, __LINE__);
}
}
}
if (forward_stdio) {