diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2020-12-30 20:03:43 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2020-12-31 12:16:46 +0000 |
commit | e334d6f9a763054d7f290bf6de5e79d205b4e21c (patch) | |
tree | 055789b9b36c8bf736e086fb4e5add14716d8dbf /src | |
parent | 04c34eb7992c88a84b04928985c231c44694ae8f (diff) |
QProcess: allow pipelining for detached processes
[ChangeLog][QtCore][QProcess] Added support for
setStandardOutputProcess() with startDetached().
Change-Id: I61278cdb7084127f583c8c017688da392017b44c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
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. |