Skip to content

Commit

Permalink
unix: don't close the fds we just setup
Browse files Browse the repository at this point in the history
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

PR-URL: libuv#309
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
  • Loading branch information
sam-github authored and saghul committed Apr 10, 2015
1 parent a7e7baf commit 55cc5ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/unix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 55cc5ba

Please sign in to comment.