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.



  • 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 Starting state appear for a very short time, in void QProcessPrivate::startProcess(), set at begining, changed to Running / NotRunning after 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::Starting and 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?


  • Lifetime Qt Champion

    @Gerald-L said in How to force kill a QProcess instance when it's state() is Starting.:

    Should I wait for the process started?

    I would do it like this, yes


Log in to reply