diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index b7c7c4bab41..7cd379f9fd2 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -660,6 +660,11 @@ static void applyProcessParameters(const QProcess::UnixProcessParameters ¶ms if (!ignore_sigpipe || sig != SIGPIPE) QtVforkSafe::sigaction(sig, &sa, nullptr); } + + // and unmask all signals + sigset_t set; + sigemptyset(&set); + sigprocmask(SIG_SETMASK, &set, nullptr); } // Close all file descriptors above stderr. diff --git a/tests/auto/corelib/io/qprocess/testUnixProcessParameters/main.cpp b/tests/auto/corelib/io/qprocess/testUnixProcessParameters/main.cpp index e701677403d..9be19306677 100644 --- a/tests/auto/corelib/io/qprocess/testUnixProcessParameters/main.cpp +++ b/tests/auto/corelib/io/qprocess/testUnixProcessParameters/main.cpp @@ -30,17 +30,30 @@ int main(int argc, char **argv) } if (cmd == "reset-sighand") { - // confirm it was not ignored + bool ok = true; + + // confirm our signal block mask is empty + sigset_t set; + sigprocmask(SIG_SETMASK, nullptr, &set); + for (int signo = 1; signo < NSIG; ++signo) { + if (sigismember(&set, signo)) { + fprintf(stderr, "'%s' is blocked.\n", strsignal(signo)); + ok = false; + } + } + + // confirm SIGUSR1 was not ignored struct sigaction action; sigaction(SIGUSR1, nullptr, &action); - if (action.sa_handler == SIG_DFL) - return EXIT_SUCCESS; - fprintf(stderr, "SIGUSR1 is SIG_IGN\n"); - return EXIT_FAILURE; + if (action.sa_handler != SIG_DFL) { + fprintf(stderr, "SIGUSR1 is SIG_IGN\n"); + ok = false; + } + return ok ? EXIT_SUCCESS : EXIT_FAILURE; } if (cmd == "ignore-sigpipe") { - // confirm it was ignored + // confirm SIGPIPE was ignored struct sigaction action; sigaction(SIGPIPE, nullptr, &action); if (action.sa_handler == SIG_IGN) diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 7c318f0ca7f..609a6e11138 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1562,6 +1562,11 @@ void tst_QProcess::unixProcessParameters() sigaction(SIGUSR1, &act, &old_sigusr1); act.sa_handler = SIG_DFL; sigaction(SIGPIPE, &act, &old_sigpipe); + + // and we block SIGUSR2 + sigset_t *set = &act.sa_mask; // reuse this sigset_t + sigaddset(set, SIGUSR2); + sigprocmask(SIG_BLOCK, set, nullptr); } ~Scope() { @@ -1574,6 +1579,10 @@ void tst_QProcess::unixProcessParameters() sigaction(SIGUSR1, &old_sigusr1, nullptr); sigaction(SIGPIPE, &old_sigpipe, nullptr); devnull = -1; + + sigset_t *set = &old_sigusr1.sa_mask; // reuse this sigset_t + sigaddset(set, SIGUSR2); + sigprocmask(SIG_BLOCK, set, nullptr); } } scope;