I have seen lately a couple of programs that can be launched as daemons (e.g. linphonecsh) but also offer a second invocation method that will exchange information with the running daemon. In the linpohone case, linephonecsh with one set of parms launches the daemon but if invoked with a different set of parms it can query the status of the daemon (call in progress, call duration, hangup, exit, etc.).
So, since I need to write an app that could go either way, app or daemon, I was wonering about how one does this neat trick. I suppose UNIX domain sockets would work as might named interprocess pipes. D-bus perhaps?
And where might one see a good C/C++ example of this?
Any suggestion and alternate approaches are solicited.
You have a few options:
You should decide which one suits you best, based on the details of your task. I assume you’re on Linux, so a chapter from the book “Advanced Linux Programming” on inter-process communication will help. It provides code examples, too.