summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-11-25 15:25:33 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2020-12-01 15:45:17 +0200
commit80b7ef559a844e4f2f822c15a7f7a766d1fc38e2 (patch)
tree23f5b63fab7c2f03f058e26fe7260faf03750823 /src/corelib/io/qprocess_win.cpp
parent6035fd8f2c23357c46c401fb7120af83e5cf5887 (diff)
QProcess/Win: improve reading in waitForBytesWritten()
On Windows, tryReadFromChannel() just publishes the data that was already buffered by the pipe reader. Reading from the pipe was still possible only because the pipe writer enters an alertable wait state which can trigger an I/O callback for the read operation as well. This made the implementation unclear and tied to APC behavior. To avoid this, we now call the "proper" pipe reader wait function instead, which also unifies the code with the other waitFor...() implementations. Change-Id: I7376d7973477a722472ff8763f95f39e6ea2fce9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 2663316de0..58cec1ba3a 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -758,18 +758,12 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
return true;
// If we wouldn't write anything, check if we can read stdout.
- if (stdoutChannel.pipe[0] != INVALID_Q_PIPE
- && bytesAvailableInChannel(&stdoutChannel) != 0) {
- tryReadFromChannel(&stdoutChannel);
+ if (stdoutChannel.reader && stdoutChannel.reader->waitForReadyRead(0))
timer.resetIncrements();
- }
// Check if we can read stderr.
- if (stderrChannel.pipe[0] != INVALID_Q_PIPE
- && bytesAvailableInChannel(&stderrChannel) != 0) {
- tryReadFromChannel(&stderrChannel);
+ if (stderrChannel.reader && stderrChannel.reader->waitForReadyRead(0))
timer.resetIncrements();
- }
// Check if the process died while reading.
if (!pid)