0

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.

asked Nov 22, 2014 at 23:44
3
  • tldp.org/LDP/tlk/ipc/ipc.html Just google for "Linux inter-process communication". Commented Nov 22, 2014 at 23:48
  • Poor example. Chrome runs as multiple processes. Commented Nov 22, 2014 at 23:50
  • You could use pipes, etc, as @Shemhamforasch suggests, but usually GUI programs use the operating system's message bus. It's also common for platforms such as windows to have the 'launch as window' stuff builtin to the executor. I don't know the details, so not quite an answer. Commented Nov 22, 2014 at 23:51

2 Answers 2

2

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.

answered Nov 23, 2014 at 1:47
Sign up to request clarification or add additional context in comments.

3 Comments

Actually, it's mine. I am programming a server, and I wanna do it able to change some settings using CLI. Then, I would like what would be best way to provide a interface to do that.
Then you should use whatever is convenient for you—if I were you I would probably just use whatever you are using for the server. If your server is an HTTPd, use HTTP. If it's ZeroMQ, use ZeroMQ, etc. If you are writing a network server just bind to a local port. If you are writing a D-Bus server use D-Bus, etc. There is no one true way to do this, so usually it is best to just leverage whatever existing infrastructure you already have in place.
Thanks for your answer. When you told about local port, I've searched a little and found some stuffs about Unix Domain Sockets, which limits access just to local applications.
0

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.

answered Nov 23, 2014 at 1:28

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.