From db5c90159437e84024f8a983a0de5d310f2d0307 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 6 Jan 2021 17:12:17 +0200 Subject: [PATCH] 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 --- src/corelib/io/qprocess_unix.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 17a1425d3f4..2f21e0ee1ed 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; }