Checking if application is still live?
-
I have an application that launches other applications, I pass the child applications the PID of the launching application via the command line.
I want the child application to check if the launching application is still live by checking if the PID is still active. Is there a function to do this in Qt? I know that QProcess can check the applications own PID, but is there a facility to do this for another?
-
@SPlatten said in Checking if application is still live?:
When the main application is terminated I want the child modules to terminate themselves
For the record, that's exactly what
QProcess::start()
will cause. In a robust fashion, if they don't acknowledge. If that's all you want the heartbeat for. -
Hi,
I am not aware of such a functionality out of the box.
Out of curiosity, can you explain why the child application needs to check that ? This might help finding a good solution.
-
@SGaist , the main (launching) application is the application engine, it reads the modules that it will launch from an XML configuration file. The modules provide additional functionality that isn't in the engine, for example file I/O or database access. These modules are slaves to the main application, the main application issues requests to the applications and the child modules respond.
When the main application is terminated I want the child modules to terminate themselves, originally I thought of issuing a message from the main application however this doesn't work if for some reason the main application dies or is terminated so I thought each module could check if the main application is still up and running...I could also do this by sending a message from the modules, which I already do as each module issues a heartbeat message to the launcher to notify it that the module is still up and running....I might just make the main application send an 'ack' in response to receiving a heartbeat and then the module could terminate if it doesn't receive a heartbeat in a timely manor.
-
A bidirectional heart beat is a good solution.
I have implemented something like that using ZMQ which works nicely and is platform independent.
-
@SPlatten said in Checking if application is still live?:
When the main application is terminated I want the child modules to terminate themselves
For the record, that's exactly what
QProcess::start()
will cause. In a robust fashion, if they don't acknowledge. If that's all you want the heartbeat for.