From bc9cd5634541ee9f1cab7eb643c78766045347c8 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 11 Mar 2022 12:05:24 -0500 Subject: [PATCH] process: reset the signal mask if the fork fails (#3537) Fix a regression that sneaked into posix spawn changes. Refs: https://github.com/libuv/libuv/pull/3257 --- src/unix/process.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/unix/process.c b/src/unix/process.c index 8802e4f30..c8816b85b 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; }