I've been googling around looking for a way to properly and cleanly start a series of binaries wich are pipeed toghether, and let all the whole stuff be launched normaly as a series of daemons would be... but no luck with this.
In a nutshell, here's my command:
ossrecord -s48000 -b16 -c2 -d/dev/oss/oss_envy24ht0/pcmin0 - | opusenc --bitrate 96 - - | oggfwd 192.168.1.12 7000 mysecret /mystream.opus
Basically it grabs oss v4 pcm audio from a capure device, pipes the output aout to opusenc binary, which in turn encodes it to opus format, and finally, I pipe the result out to a icecast2 server (all this is more or less nicely documented on the opus docs) And it works nicely!
The problem is that all this ocurs on the cli, it captures stdout ans starts yelding output. Being all that stuff a series of piped processes I dont manage to control them. Moreover, it would be nice to have some kind of launching/stopping script, that would make it possible to have all this running in the background.
I have being struggling with start-stop-daemon as I usually do, but my knowledge basically covers handling a single binary and its paramenters (as found on docs), and I think I'm blindly stepping on holy guru's domains.
So, maybe someone may find out how this can be totally or partially acomplished.
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:
SIGTERM
,SIGINT
orSIGQUIT
is send to the program, it terminates all it's children and then itself.SIGHUP
is sent to pipexec it restarts all the children (including the pipes in between them).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
andkillproc
and it works seamlessly. The pid file feature was used here.Kind regards - Andreas