QProcess/Unix: don't set the SIGPIPE signal handler twice

If the user is asking us to ignore it, don't set to the default
behavior.

Change-Id: Ib5ce7a497e034ebabb2cfffd17628562f745358d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Thiago Macieira 2023-05-25 16:04:30 -07:00
parent 52ed6af527
commit bf67518b53

View File

@ -799,8 +799,6 @@ static void callChildProcessModifier(const QProcessPrivate *d) noexcept
// still sharing memory with the parent process.
void QChildProcess::startProcess() const noexcept
{
QtVforkSafe::change_sigpipe(SIG_DFL); // reset the signal that we ignored
// Render channels configuration.
d->commitChannels();
@ -811,6 +809,7 @@ void QChildProcess::startProcess() const noexcept
if (workingDirectory >= 0 && fchdir(workingDirectory) == -1)
failChildProcess(d, "fchdir", errno);
bool sigpipeHandled = false;
if (d->unixExtras) {
// FIRST we call the user modifier function, before we dropping
// privileges or closing non-standard file descriptors
@ -818,6 +817,13 @@ void QChildProcess::startProcess() const noexcept
// then we apply our other user-provided parameters
applyProcessParameters(d->unixExtras->processParameters);
auto flags = d->unixExtras->processParameters.flags;
sigpipeHandled = flags.testAnyFlags(QProcess::ResetSignalHandlers | QProcess::IgnoreSigPipe);
}
if (!sigpipeHandled) {
// reset the signal that we ignored
QtVforkSafe::change_sigpipe(SIG_DFL); // reset the signal that we ignored
}
// execute the process