diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-01-06 17:12:17 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-01-09 15:16:34 +0200 |
commit | db5c90159437e84024f8a983a0de5d310f2d0307 (patch) | |
tree | ba7d6df493cfe2926ef6fb6d269824d9cd044c6e /src/corelib | |
parent | 6a6d12ea4b90d24839f13b92237dbc8cce5eaf9d (diff) |
QProcess/Unix: do not activate read notifiers until process has started
Otherwise, the user may receive the readyRead() signal just before
started().
Change-Id: I8d6fd18fdfcef0580a3e609100198b03b18b1175
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 17a1425d3f..2f21e0ee1e 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -239,8 +239,8 @@ bool QProcessPrivate::openChannel(Channel &channel) QObject::connect(channel.notifier, SIGNAL(activated(QSocketDescriptor)), q, SLOT(_q_canWrite())); } else { - channel.notifier = new QSocketNotifier(channel.pipe[0], - QSocketNotifier::Read, q); + channel.notifier = new QSocketNotifier(QSocketNotifier::Read, q); + channel.notifier->setSocket(channel.pipe[0]); const char *receiver; if (&channel == &stdoutChannel) receiver = SLOT(_q_canReadStandardOutput()); @@ -602,6 +602,10 @@ bool QProcessPrivate::processStarted(QString *errorMessage) stateNotifier->setSocket(forkfd); stateNotifier->setEnabled(true); } + if (stdoutChannel.notifier) + stdoutChannel.notifier->setEnabled(true); + if (stderrChannel.notifier) + stderrChannel.notifier->setEnabled(true); return true; } |