summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-12-02 17:22:10 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2020-12-06 22:28:31 +0200
commitec02de374da3f796a2155b45779be222a90be2cd (patch)
tree35465504521bb2162506e46231f11e2754703091 /src/corelib/io
parent895940a42505e4383971e84954a0deaebad3dbab (diff)
QProcess: simplify the logic around _q_processDied()
Both on Unix and Windows, _q_processDied() unconditionally releases all resources associated with the terminated child process, resets QProcess to the initial state, and emits finished() signal. Thus, we can omit reporting success, which also eliminates the related checks from callers. Change-Id: I40e32d1a9ccc8d488be6badba934355d734a8abd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qprocess.cpp10
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qprocess_p.h4
-rw-r--r--src/corelib/io/qprocess_unix.cpp17
4 files changed, 15 insertions, 18 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 8b29a8964f..e7d671abc8 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1057,15 +1057,14 @@ bool QProcessPrivate::_q_canWrite()
/*!
\internal
*/
-bool QProcessPrivate::_q_processDied()
+void QProcessPrivate::_q_processDied()
{
Q_Q(QProcess);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::_q_processDied()");
#endif
#ifdef Q_OS_UNIX
- if (!waitForDeadChild())
- return false;
+ waitForDeadChild();
#endif
#ifdef Q_OS_WIN
if (processFinishedNotifier)
@@ -1078,7 +1077,7 @@ bool QProcessPrivate::_q_processDied()
// give it a chance to emit started() or errorOccurred(FailedToStart).
if (processState == QProcess::Starting) {
if (!_q_startupNotification())
- return true;
+ return;
}
if (dying) {
@@ -1086,7 +1085,7 @@ bool QProcessPrivate::_q_processDied()
// reentering this slot recursively by calling waitForFinished()
// or opening a dialog inside slots connected to the readyRead
// signals emitted below.
- return true;
+ return;
}
dying = true;
@@ -1119,7 +1118,6 @@ bool QProcessPrivate::_q_processDied()
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::_q_processDied() process is dead");
#endif
- return true;
}
/*!
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index cfa86c8508..86c778d511 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -283,7 +283,7 @@ private:
Q_PRIVATE_SLOT(d_func(), bool _q_canReadStandardError())
Q_PRIVATE_SLOT(d_func(), bool _q_canWrite())
Q_PRIVATE_SLOT(d_func(), bool _q_startupNotification())
- Q_PRIVATE_SLOT(d_func(), bool _q_processDied())
+ Q_PRIVATE_SLOT(d_func(), void _q_processDied())
friend class QProcessManager;
};
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 1f449bd4c8..decd6c98f5 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -295,7 +295,7 @@ public:
bool _q_canReadStandardError();
bool _q_canWrite();
bool _q_startupNotification();
- bool _q_processDied();
+ void _q_processDied();
QProcess::ProcessChannelMode processChannelMode = QProcess::SeparateChannels;
QProcess::InputChannelMode inputChannelMode = QProcess::ManagedInputChannel;
@@ -354,7 +354,7 @@ public:
void killProcess();
void findExitCode();
#ifdef Q_OS_UNIX
- bool waitForDeadChild();
+ void waitForDeadChild();
#endif
#ifdef Q_OS_WIN
bool callCreateProcess(QProcess::CreateProcessArguments *cpargs);
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 9e5b26b3d6..437d2872dd 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -768,8 +768,8 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
return false;
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
- if (_q_processDied())
- return false;
+ _q_processDied();
+ return false;
}
}
return false;
@@ -818,8 +818,8 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
return false;
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
- if (_q_processDied())
- return false;
+ _q_processDied();
+ return false;
}
}
@@ -867,8 +867,8 @@ bool QProcessPrivate::waitForFinished(int msecs)
return true;
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
- if (_q_processDied())
- return true;
+ _q_processDied();
+ return true;
}
}
return false;
@@ -878,10 +878,10 @@ void QProcessPrivate::findExitCode()
{
}
-bool QProcessPrivate::waitForDeadChild()
+void QProcessPrivate::waitForDeadChild()
{
if (forkfd == -1)
- return true; // child has already exited
+ return; // child has already been reaped
// read the process information from our fd
forkfd_info info;
@@ -901,7 +901,6 @@ bool QProcessPrivate::waitForDeadChild()
qDebug() << "QProcessPrivate::waitForDeadChild() dead with exitCode"
<< exitCode << ", crashed?" << crashed;
#endif
- return true;
}
bool QProcessPrivate::startDetached(qint64 *pid)