IPC (Message Queues vs. FIFOs vs. Unix-domain Sockets)
Hi.
I'm writing a program which forks, the parent exiting immediately, the child doing the necessary stuff to become a daemon and then writing its PID to a file. When the program is invoked again, it checks if the daemon is already running and if so, I'd like it to pass its command-line arguments to the daemon. Message Queues look to be a good solution to this, but after some research it seems that they are vaguely frowned-upon. Is there are a good reason not to use them? Would a named-pipe or a Unix-domain socket be a better solution? Some advice would be much appreciated.
Ultimately the daemons's goal is to control some other processes which periodically print status information to the console. My plan is for the daemon to fork each time it is asked to start a process and for the child to read the controlled process' output via a pipe. The daemon will need to be able to ask its children for the status of their controlled processes, which it will then collate and send back to the instance that woke it up, so that it can be printed to the console. Is this a reasonable design? Would message queues again be a sensible solution for this second teir? As the daemon will always outlive its children, a fourth option would be to communicate via inherited file descriptors. Again some advice would be very much appreciated.
Thanks.
|