From 9d71d1cab5fbed7d96cb03a58887f052b01ccc3e Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 31 Jul 2012 19:38:43 +0200 Subject: [PATCH] windows/uv_spawn: ignore errors when duplicating fd 0-2 fails Hopefully this fixes joyent/node#3779. --- src/win/process-stdio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/win/process-stdio.c b/src/win/process-stdio.c index 2ae9a143..c98e2e47 100644 --- a/src/win/process-stdio.c +++ b/src/win/process-stdio.c @@ -330,6 +330,13 @@ int uv__stdio_create(uv_loop_t* loop, uv_process_options_t* options, /* Make an inheritable duplicate of the handle. */ if (uv__duplicate_fd(loop, fdopt.data.fd, &child_handle) < 0) { + /* If fdopt.data.fd is not valid and fd fd <= 2, then ignore the */ + /* error. */ + if (fdopt.data.fd <= 2 && loop->last_err.code == UV_EBADF) { + CHILD_STDIO_CRT_FLAGS(buffer, i) = 0; + CHILD_STDIO_HANDLE(buffer, i) = NULL; + break; + } goto error; }