PDA

View Full Version : Sending signal to other process?



Boron
26th August 2009, 18:05
Hello,
when a special button is clicked my application starts a new process with a different application QProcess::startDetached( "OtherApp.exe" );
Now I want the new application to signal the first application to quit.

First I thought about using D-Bus for Inter-Process Communication (IPC), but as I am developing for Windows D-Bus cannot be used (Unix only).
QCOP is for Qt Embedded Linux only.
This leaves TCP/IP and Shared Memory as remainders of the proposed ways to implement IPC.

But how can I use them (or only one of them) to signal from one application to another?
Are there other ways to achieve this?

wysota
26th August 2009, 18:25
You can also communicate through a pipe or using PostMessage() which is a WinAPI call.

Boron
26th August 2009, 20:35
I will try PostMessage() and its counterpart GetMessage() (right?).

I have another idea: Using a QSharedMemory and placing a flag in it. The new app sets the flag to true when the first app has to quit. The first app waits for the flag to be set to true (non-blocking of course).

miwarre
28th August 2009, 10:06
I don't know if you already solved your issue, but just in case...


I will try PostMessage() and its counterpart GetMessage() (right?).
Well, you don't really need GetMessage(): the msg posted from the other app gets routed to the first app msg loop directly by Windows, so you just need to add an additional case in the first app msg loop switch (or any other similar construct you may have used).

Note: to use PostMessage(), you need the handle of a window beloging to the target app; if the first app has a window with a specific class and/or title, you may find it with FindWindow().

The whole is very Windows-specific, though. So...

I have another idea: Using a QSharedMemory and placing a flag in it. The new app sets the flag to true when the first app has to quit. The first app waits for the flag to be set to true (non-blocking of course).
This sounds much more platform-independent, fast and simple!! I would try it first.

Ciao,

M.