Skip to content

Commit 2d4939c

Browse files
sam-githubsaghul
authored andcommitted
unix: don't close the fds we just setup
If a descriptor was being copied to an fd that *was not its current value*, it should get closed after being copied. But the existing code would close the fd, even when it no longer referred to the original descriptor. Don't do this, only close fds that are not in the desired range for the child process. See nodejs/node#862
1 parent e2e218b commit 2d4939c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/unix/process.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
316316
for (fd = 0; fd < stdio_count; fd++) {
317317
use_fd = pipes[fd][1];
318318

319-
if (use_fd >= 0 && fd != use_fd)
319+
if (use_fd >= stdio_count)
320320
close(use_fd);
321321
}
322322

0 commit comments

Comments
 (0)