Reputation: 108
I would like to know how I could communicate with a running proccess, like Google Chrome does. If it already exist any instance of Google Chrome and you click in a external link (inside or outside browser), it opens a new tab.
Then, my questions is this communication occurs via sockets or something like that?
Thank you.
Upvotes: 0
Views: 71
Reputation: 17472
This really depends on your platform. GTK+ has GtkApplication (which builds on the GApplication class in GIO), Qt has QtSingleApplication, etc.
GApplication/GtkApplication will basically attempt to provide a D-Bus name (at least on Linux—I believe the mechanism is platform-dependent). If it is successful then you are the original application, if not then the application is already running and you can communicate with it via D-Bus.
Upvotes: 2
Reputation: 1172
I think that combining this and this will solve your problem. Basically it makes possible to determine the pid of the running app (if there is any) and write to its stdin. You might want to signal to that process that there is new information to be processed (this should help for that).
Sockets, pipes, messages and shared memory are also nice alternatives, but at first glance this seemed to be the simplest.
Upvotes: 0