diff --git a/src/unix/process.c b/src/unix/process.c index 8802e4f3..c8816b85 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -812,11 +812,6 @@ static int uv__spawn_and_init_child_fork(const uv_process_options_t* options, *pid = fork(); - if (*pid == -1) { - /* Failed to fork */ - return UV__ERR(errno); - } - if (*pid == 0) { /* Fork succeeded, in the child process */ uv__process_child_init(options, stdio_count, pipes, error_fd); @@ -826,6 +821,10 @@ static int uv__spawn_and_init_child_fork(const uv_process_options_t* options, if (pthread_sigmask(SIG_SETMASK, &sigoldset, NULL) != 0) abort(); + if (*pid == -1) + /* Failed to fork */ + return UV__ERR(errno); + /* Fork succeeded, in the parent process */ return 0; }