Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Control the Behaviour of one instance from another ( kill or run )
starbearer last edited by
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.
andre last edited by
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.