Created
September 15, 2011 22:18
-
-
Save ry/1220643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit be180737bf998d6a541ec1dc25c5356f2726de19 | |
Author: Ryan Dahl <ry@tinyclouds.org> | |
Date: Thu Sep 15 15:17:34 2011 -0700 | |
unix: Reset flags for stdio fds after fork | |
diff --git a/src/unix/process.c b/src/unix/process.c | |
index bbd24f4..34f12d1 100644 | |
--- a/src/unix/process.c | |
+++ b/src/unix/process.c | |
@@ -179,16 +179,28 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, | |
if (stdin_pipe[0] >= 0) { | |
uv__close(stdin_pipe[1]); | |
dup2(stdin_pipe[0], STDIN_FILENO); | |
+ } else { | |
+ /* Reset flags that might be set by Node */ | |
+ uv__cloexec(STDIN_FILENO, 0); | |
+ uv__nonblock(STDIN_FILENO, 0); | |
} | |
if (stdout_pipe[1] >= 0) { | |
uv__close(stdout_pipe[0]); | |
dup2(stdout_pipe[1], STDOUT_FILENO); | |
+ } else { | |
+ /* Reset flags that might be set by Node */ | |
+ uv__cloexec(STDOUT_FILENO, 0); | |
+ uv__nonblock(STDOUT_FILENO, 0); | |
} | |
if (stderr_pipe[1] >= 0) { | |
uv__close(stderr_pipe[0]); | |
dup2(stderr_pipe[1], STDERR_FILENO); | |
+ } else { | |
+ /* Reset flags that might be set by Node */ | |
+ uv__cloexec(STDERR_FILENO, 0); | |
+ uv__nonblock(STDERR_FILENO, 0); | |
} | |
if (options.cwd && chdir(options.cwd)) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment