diff --git a/src/unix/process.c b/src/unix/process.c index af44bc5d..80b9686e 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -279,8 +279,10 @@ static void uv__process_child_init(const uv_process_options_t* options, int stdio_count, int (*pipes)[2], int error_fd) { + sigset_t set; int close_fd; int use_fd; + int err; int fd; int n; @@ -393,6 +395,15 @@ static void uv__process_child_init(const uv_process_options_t* options, _exit(127); } + /* Reset signal mask. */ + sigemptyset(&set); + err = pthread_sigmask(SIG_SETMASK, &set, NULL); + + if (err != 0) { + uv__write_int(error_fd, -err); + _exit(127); + } + execvp(options->file, options->args); uv__write_int(error_fd, -errno); _exit(127); diff --git a/test/test-spawn.c b/test/test-spawn.c index 1ec6bc13..bb35e32b 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -931,6 +931,12 @@ TEST_IMPL(kill) { /* Verify that uv_spawn() resets the signal disposition. */ #ifndef _WIN32 + { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGTERM); + ASSERT(0 == pthread_sigmask(SIG_BLOCK, &set, NULL)); + } ASSERT(SIG_ERR != signal(SIGTERM, SIG_IGN)); #endif @@ -938,6 +944,12 @@ TEST_IMPL(kill) { ASSERT(r == 0); #ifndef _WIN32 + { + sigset_t set; + sigemptyset(&set); + sigaddset(&set, SIGTERM); + ASSERT(0 == pthread_sigmask(SIG_UNBLOCK, &set, NULL)); + } ASSERT(SIG_ERR != signal(SIGTERM, SIG_DFL)); #endif