PDA

View Full Version : How do I close a QProcess after a main app crash/terminate



hybrid_snyper
18th July 2012, 14:43
Hi,

What can I do about a QProcess that is still running after the main application has not closed down cleanly.

For example if I start running my application in QtCreator and then hit 'Stop' to terminate the program the external process that I launched using QProcess is still running. Without using killall on the next run what are my options? It is imperative that I don't run multiple instances of this process.

Thanks

H

yeye_olive
18th July 2012, 15:33
You could obtain the list of running processes and look for an existing instance of the child process. I do not know a readily available platform-independent wrapper to do so. Under Windows, you can use EnumProcesses() or the Tool Help library; under Linux, see the /proc filesystem; I do not remember how to do it under MacOS X.

In any case this will never prevent anyone to run as many instances of the process as they wish after your program has tested that none was currently running.