Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to force kill a QProcess instance when it's state() is Starting.
Gerald.L. last edited by Gerald.L.
When I try to force kill a QProcess instance, how should I deal with the case
process->state() == QProcess::Starting?
I checked the Qt source code, the
Startingstate appear for a very short time, in
void QProcessPrivate::startProcess(), set at begining, changed to
forkfd()( a wrapper of
fork()?) success /fail. The
QProcess::kill()member function I use to force kill process uses the pid returned from
forkfd(). So, when
process->state() == QProcess::Startingand
kill()is called, whether the child-process pid is there is not certain.
Should I wait for the process started? What's the elegant way to force kill a QProcess instance?
Should I wait for the process started?
I would do it like this, yes