I came across exactly the same problem and decided for me to solve this once and forever ;-) [One reason was your question here at stackoverflow without an answer or even a comment.]
Therefore I wrote a small program called pipexec. The features in a nutshell:
- Starts programs and pipes them together.
- When a
SIGTERM
,SIGINT
orSIGQUIT
is send to the program, it terminates all it's children and then itself. - When a
SIGHUP
is sent to pipexec it restarts all the children (including the pipes in between them). - When a child terminates un-normally (e.g. by a signal), all children are terminated and restarted (including the pipes).
- Support for pid file.
It's written in plain C99 with Linux in mind. 500 lines of code resulting in about 20k executable. I integrated pipexec
into the RHEL6 using /etc/init.d/functions
daemon
and killproc
and it works seamlessly. The pid file feature was used here.
Kind regards - Andreas