From e334d6f9a763054d7f290bf6de5e79d205b4e21c Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 30 Dec 2020 20:03:43 +0200 Subject: QProcess: allow pipelining for detached processes [ChangeLog][QtCore][QProcess] Added support for setStandardOutputProcess() with startDetached(). Change-Id: I61278cdb7084127f583c8c017688da392017b44c Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index bd25910976..842d219a43 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -982,33 +982,38 @@ bool QProcessPrivate::openChannels() bool QProcessPrivate::openChannelsForDetached() { // stdin channel. + bool needToOpen = (stdinChannel.type == Channel::Redirect + || stdinChannel.type == Channel::PipeSink); if (stdinChannel.type != Channel::Normal - && (stdinChannel.type != Channel::Redirect + && (!needToOpen || inputChannelMode == QProcess::ForwardedInputChannel)) { qWarning("QProcess::openChannelsForDetached: Inconsistent stdin channel configuration"); } - if (stdinChannel.type == Channel::Redirect && !openChannel(stdinChannel)) + if (needToOpen && !openChannel(stdinChannel)) return false; // stdout channel. + needToOpen = (stdoutChannel.type == Channel::Redirect + || stdoutChannel.type == Channel::PipeSource); if (stdoutChannel.type != Channel::Normal - && (stdoutChannel.type != Channel::Redirect + && (!needToOpen || processChannelMode == QProcess::ForwardedChannels || processChannelMode == QProcess::ForwardedOutputChannel)) { qWarning("QProcess::openChannelsForDetached: Inconsistent stdout channel configuration"); } - if (stdoutChannel.type == Channel::Redirect && !openChannel(stdoutChannel)) + if (needToOpen && !openChannel(stdoutChannel)) return false; // stderr channel. + needToOpen = (stderrChannel.type == Channel::Redirect); if (stderrChannel.type != Channel::Normal - && (stderrChannel.type != Channel::Redirect + && (!needToOpen || processChannelMode == QProcess::ForwardedChannels || processChannelMode == QProcess::ForwardedErrorChannel || processChannelMode == QProcess::MergedChannels)) { qWarning("QProcess::openChannelsForDetached: Inconsistent stderr channel configuration"); } - if (stderrChannel.type == Channel::Redirect && !openChannel(stderrChannel)) + if (needToOpen && !openChannel(stderrChannel)) return false; return true; @@ -2175,6 +2180,7 @@ void QProcess::startCommand(const QString &command, OpenMode mode) \li setStandardInputFile() \li setStandardOutputFile() \li setProcessChannelMode(QProcess::MergedChannels) + \li setStandardOutputProcess() \li setWorkingDirectory() \endlist All other properties of the QProcess object are ignored. -- cgit v1.2.3