From bd7eb131782286d5b41fb1a5b9de0350b4968e3b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 23 Jul 2018 08:25:56 +0200 Subject: 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 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_unix.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index a849519635..713af9bd40 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -949,16 +949,14 @@ bool QProcessPrivate::startDetached(qint64 *pid) qt_safe_close(pidPipe[1]); // 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); // copy the stdout and stderr if asked to - if (processChannelMode != QProcess::ForwardedChannels) { - if (processChannelMode != QProcess::ForwardedOutputChannel) - qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0); - if (processChannelMode != QProcess::ForwardedErrorChannel) - qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0); - } + if (stdoutChannel.type == Channel::Redirect) + qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0); + if (stderrChannel.type == Channel::Redirect) + qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0); if (!encodedWorkingDirectory.isEmpty()) { if (QT_CHDIR(encodedWorkingDirectory.constData()) == -1) -- cgit v1.2.3