QProcess/Unix: reset the signal block if ResetSignalHandlers requested
This amends commit f9c87cfd44bcf4b90cb45354252ef19f647b0469 to reset the signal block mask too, not just the signal handlers. For this, SIGPIPE is not treated specially. Change-Id: Ib5ce7a497e034ebabb2cfffd17627289614bf315 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 062b2ac71bac1e0449eff7f8f02cb0020ad39991) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0dc6ccbc5c
commit
d75414372d
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user