Skip to content

Commit 6131f4c

Browse files
committed
Close fds explicitly
1 parent ced282c commit 6131f4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kitty/child.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ spawn(PyObject *self UNUSED, PyObject *args) {
136136
int fd = PyLong_AsLong(pfd);
137137
if (fd > -1) {
138138
if (fd == min_closed_fd) min_closed_fd++;
139-
else if (safe_dup2(fd, min_closed_fd++) == -1) exit_on_err("dup2() failed for forwarded fd 1");
139+
else {
140+
if (safe_dup2(fd, min_closed_fd++) == -1) exit_on_err("dup2() failed for forwarded fd 1");
141+
safe_close(fd, __FILE__, __LINE__);
142+
}
140143
}
141144
}
142145
if (forward_stdio) {

0 commit comments

Comments
 (0)