Control the Behaviour of one instance from another ( kill or run )
-
I have a QtSingleApplication.
I've started an instance A.
Next I start an instance B.
B uses sendmessage() to send a message to A.
A uses this message ( received with messageReceived() signal )to determine whether B should continue running or not.
How do I inform B of this decision?
I had thought of inserting the process ID of B..with the message sent to A, and using this process ID, perhaps A can force B's closure or have it continue?
If this is a correct flow, how do I get the process Id ( I don't know whether there'll be one for QtSingleApplication, or for a process, and if Pid QProcess::processID() ), will be any good? ).
Also, once I have it, how do I force B's closure? Or inform it of any message?
Please help me with it. Thank you.
-
I think that I'd make B listen on a port, and communicate the port number to A. Then A can open a connection to B on that port, and you can use a simple protocol over TCP to communicate between the instances. You could also considder using a solution like "QxtRPCPeer":http://libqxt.bitbucket.org/doc/0.6/qxtrpcpeer.html for your communication.