summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-12-08 20:42:34 +0200
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2020-12-09 11:48:36 +0000
commitdccc2aff6cb0bc480c6272536f595936e4ebc31d (patch)
treed44b0b9cd7f85b19b02db1bcaf83a0d4f247d408 /src
parentddc585b7c773786045f3658d7da5425ed2f2f786 (diff)
QProcess/Unix: unify waiting in 'Starting' state
It makes no sense to poll the I/O pipes if we didn't get a start-up notification yet. And in fact, all waitFor...() functions except waitForReadyRead() did already explicitly wait for process startup completion. So fix that one up, and remove the handling of 'Starting' state from the I/O loops. Change-Id: Ibb7eb7c768bef3f9b6c54009c73b91775570102c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qprocess.cpp10
-rw-r--r--src/corelib/io/qprocess_unix.cpp23
2 files changed, 11 insertions, 22 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 1583f31e34..fb769ef74c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1783,7 +1783,15 @@ bool QProcess::waitForReadyRead(int msecs)
return false;
if (d->currentReadChannel == QProcess::StandardError && d->stderrChannel.closed)
return false;
- return d->waitForReadyRead(QDeadlineTimer(msecs));
+
+ QDeadlineTimer deadline(msecs);
+ if (d->processState == QProcess::Starting) {
+ bool started = d->waitForStarted(deadline);
+ if (!started)
+ return false;
+ }
+
+ return d->waitForReadyRead(deadline);
}
/*! \reimp
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 636f6f2e22..bb52233a9c 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -157,9 +157,8 @@ struct QProcessPoller
pollfd &stdoutPipe() { return pfds[1]; }
pollfd &stderrPipe() { return pfds[2]; }
pollfd &forkfd() { return pfds[3]; }
- pollfd &childStartedPipe() { return pfds[4]; }
- enum { n_pfds = 5 };
+ enum { n_pfds = 4 };
pollfd pfds[n_pfds];
};
@@ -177,15 +176,11 @@ QProcessPoller::QProcessPoller(const QProcessPrivate &proc)
}
forkfd().fd = proc.forkfd;
-
- if (proc.processState == QProcess::Starting)
- childStartedPipe().fd = proc.childStartedPipe[0];
}
int QProcessPoller::poll(const QDeadlineTimer &deadline)
{
- const nfds_t nfds = (childStartedPipe().fd == -1) ? 4 : 5;
- return qt_poll_msecs(pfds, nfds, deadline.remainingTime());
+ return qt_poll_msecs(pfds, n_pfds, deadline.remainingTime());
}
} // anonymous namespace
@@ -740,11 +735,6 @@ bool QProcessPrivate::waitForReadyRead(const QDeadlineTimer &deadline)
return false;
}
- if (qt_pollfd_check(poller.childStartedPipe(), POLLIN)) {
- if (!_q_startupNotification())
- return false;
- }
-
// This calls QProcessPrivate::tryReadFromChannel(), which returns true
// if we emitted readyRead() signal on the current read channel.
bool readyReadEmitted = false;
@@ -791,11 +781,6 @@ bool QProcessPrivate::waitForBytesWritten(const QDeadlineTimer &deadline)
return false;
}
- if (qt_pollfd_check(poller.childStartedPipe(), POLLIN)) {
- if (!_q_startupNotification())
- return false;
- }
-
if (qt_pollfd_check(poller.stdinPipe(), POLLOUT))
return _q_canWrite();
@@ -837,10 +822,6 @@ bool QProcessPrivate::waitForFinished(const QDeadlineTimer &deadline)
return false;
}
- if (qt_pollfd_check(poller.childStartedPipe(), POLLIN)) {
- if (!_q_startupNotification())
- return false;
- }
if (qt_pollfd_check(poller.stdinPipe(), POLLOUT))
_q_canWrite();