How to check if a Process is Running or Not

qt

Solution

From the docs for QProcess ...

There are at least 3 ways to check if a QProcess instance is running.

QProcess.pid() : If its running, the pid will be > 0

QProcess.state() : Check it again the ProcessState enum to see if its QProcess::NotRunning

QProcess.atEnd() : Its not running if this is true

If any of these are not working as you would expect, then you will need to post a specific case of that example.

Problem

I am starting a process using the below code ``` QProcess* process = new QProcess(); process->start(Path); ``` The start method will start a third party application. If the process is already running, I should not call process->start(Path) again. The process pointer is private member of the class.

Original source