Fix conditions for dup2 in QProcess::startDetached

The channel pipes are only set up if the channel's type is
Redirect. Fix the conditions accordingly.

This amends commit 7ad55ca6.

Change-Id: Ie8a800fbe2bf9f5f6709b14ba03133b80e9b4bef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
Joerg Bornemann 2018-07-23 08:25:56 +02:00
parent d3cbabcc6d
commit bd7eb13178

View File

@ -949,16 +949,14 @@ bool QProcessPrivate::startDetached(qint64 *pid)
qt_safe_close(pidPipe[1]); qt_safe_close(pidPipe[1]);
// copy the stdin socket if asked to (without closing on exec) // copy the stdin socket if asked to (without closing on exec)
if (inputChannelMode != QProcess::ForwardedInputChannel) if (stdinChannel.type == Channel::Redirect)
qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO, 0); qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO, 0);
// copy the stdout and stderr if asked to // copy the stdout and stderr if asked to
if (processChannelMode != QProcess::ForwardedChannels) { if (stdoutChannel.type == Channel::Redirect)
if (processChannelMode != QProcess::ForwardedOutputChannel) qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0);
qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0); if (stderrChannel.type == Channel::Redirect)
if (processChannelMode != QProcess::ForwardedErrorChannel) qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0);
qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0);
}
if (!encodedWorkingDirectory.isEmpty()) { if (!encodedWorkingDirectory.isEmpty()) {
if (QT_CHDIR(encodedWorkingDirectory.constData()) == -1) if (QT_CHDIR(encodedWorkingDirectory.constData()) == -1)