Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have background application A.

I want to create application B to configure application A on the fly.

So, how can I detect if A is running and send some messages to A?

share|improve this question

closed as off topic by jw013, sr_, Mat, manatwork, Renan Aug 15 '12 at 2:37

Questions on Unix & Linux Stack Exchange are expected to relate to Unix or Linux within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

You could start here‌​, but I suppose in this generality this is not the right venue for your question. (If you had problems with, say, IPC via specific UNIX-y ways...) –  sr_ May 8 '12 at 9:12
@sr_ consider to convert your comment to answer –  yarek May 8 '12 at 11:02
This is probably more appropriate on –  ams May 8 '12 at 11:10
It might be appropriate here but it's hard to tell because it's worded so generally. There are many different situations where this could apply, and many different answers. Mireck, I think it would help if you better describe A and B and the environment in which they are running. –  mattdm May 8 '12 at 12:40
Do you have control over the code of prorgram A? If that's the case, I could do a small presentation of IPC. If not, I'm afraid there's no general answer. You'll have to give us the name of program A and we may look up ways to do so. –  rahmu May 8 '12 at 14:31

2 Answers 2

up vote 3 down vote accepted

If you just want to change the program's configuration, the typical method of doing that is to update its conf file, then send it a SIGHUP signal, which it is programmed to respond to by reloading its conf file ( see signal(7) ). As Coren said, you typically have the program store its pid in a file in /var/run when it starts so you can later send it the signal.

If you need more complex communication with the program, you will want to use either a fifo or unix domain socket. A fifo ( see fifo(7) and mkfifo(3) ) is simpler, but the daemon can only communicate with a single control program. Unix domain sockets ( see unix(7) ) are more complicated to use, but you can accept connections from multiple clients.

share|improve this answer

Background application are called "daemon" in Unix & Linux world.

They are standardized in many ways, one way is how to get their pid. They usually create a pid file in /var/run.

With their pid, you can know nearly everything about them with the help of /proc. You can know if it's still active, memory used, memory mapping, files open, etc, etc.

And as sr_ said, you can then use IPC methods in order to communicate with it.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.