From 55cc5bac1b6521f876b4db0f290e7992fe2b2802 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Tue, 24 Feb 2015 13:17:48 -0800 Subject: [PATCH] unix: don't close the fds we just setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/iojs/io.js/issues/862 PR-URL: https://github.com/libuv/libuv/pull/309 Reviewed-By: Ben Noordhuis Reviewed-By: Saúl Ibarra Corretgé --- src/unix/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/process.c b/src/unix/process.c index 18d056e9e50..90aa73dfb71 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -316,8 +316,8 @@ static void uv__process_child_init(const uv_process_options_t* options, for (fd = 0; fd < stdio_count; fd++) { use_fd = pipes[fd][1]; - if (use_fd >= 0 && fd != use_fd) - close(use_fd); + if (use_fd >= stdio_count) + uv__close(use_fd); } if (options->cwd != NULL && chdir(options->cwd)) {