summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2012-09-27 15:33:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-28 12:46:43 +0200
commit219b0d21747816cebf8016be6e2433394ee246c7 (patch)
tree70756a71ee85de4ac6d168733cdac87c2f803906 /src/corelib/io/qprocess_win.cpp
parent1bface4f3e123006cc85d9b262dfaa7d0d4ff0f3 (diff)
QProcess/Win fix forwarding of output channels
We must not create pipe readers for the forwarded channels as we don't want to read from stdout/stderr into the internal QProcess buffer. Also, we must not pass CREATE_NO_WINDOW to CreateProcess because this will render our stdout/stderr handles useless. Change-Id: Ie6485e86c103d1e9225cf39c04aa54093c1efe0d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 21db37c19a..dd5cf4819e 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -160,23 +160,25 @@ bool QProcessPrivate::createChannel(Channel &channel)
else
duplicateStdWriteChannel(channel.pipe, (&channel == &stdoutChannel) ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
- QWindowsPipeReader *pipeReader = 0;
- if (&channel == &stdoutChannel) {
- if (!stdoutReader) {
- stdoutReader = new QWindowsPipeReader(q);
- q->connect(stdoutReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardOutput()));
+ if (processChannelMode != QProcess::ForwardedChannels) {
+ QWindowsPipeReader *pipeReader = 0;
+ if (&channel == &stdoutChannel) {
+ if (!stdoutReader) {
+ stdoutReader = new QWindowsPipeReader(q);
+ q->connect(stdoutReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardOutput()));
+ }
+ pipeReader = stdoutReader;
+ } else if (&channel == &stderrChannel) {
+ if (!stderrReader) {
+ stderrReader = new QWindowsPipeReader(q);
+ q->connect(stderrReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardError()));
+ }
+ pipeReader = stderrReader;
}
- pipeReader = stdoutReader;
- } else if (&channel == &stderrChannel) {
- if (!stderrReader) {
- stderrReader = new QWindowsPipeReader(q);
- q->connect(stderrReader, SIGNAL(readyRead()), SLOT(_q_canReadStandardError()));
+ if (pipeReader) {
+ pipeReader->setHandle(channel.pipe[0]);
+ pipeReader->startAsyncRead();
}
- pipeReader = stderrReader;
- }
- if (pipeReader) {
- pipeReader->setHandle(channel.pipe[0]);
- pipeReader->startAsyncRead();
}
return true;
@@ -473,7 +475,9 @@ void QProcessPrivate::startProcess()
qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
#endif
- DWORD dwCreationFlags = CREATE_NO_WINDOW;
+ // Forwarded channels must not set the CREATE_NO_WINDOW flag because this
+ // will render the stdout/stderr handles we're passing useless.
+ DWORD dwCreationFlags = (processChannelMode == QProcess::ForwardedChannels ? 0 : CREATE_NO_WINDOW);
dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
(ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,