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>
This commit is contained in:
Joerg Bornemann 2012-09-27 15:33:45 +02:00 committed by The Qt Project
parent 1bface4f3e
commit 219b0d2174

View File

@ -160,6 +160,7 @@ bool QProcessPrivate::createChannel(Channel &channel)
else
duplicateStdWriteChannel(channel.pipe, (&channel == &stdoutChannel) ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
if (processChannelMode != QProcess::ForwardedChannels) {
QWindowsPipeReader *pipeReader = 0;
if (&channel == &stdoutChannel) {
if (!stdoutReader) {
@ -178,6 +179,7 @@ bool QProcessPrivate::createChannel(Channel &channel)
pipeReader->setHandle(channel.pipe[0]);
pipeReader->startAsyncRead();
}
}
return true;
} else if (channel.type == Channel::Redirect) {
@ -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,