I am starting following command from a bash script (arguments omitted for simplicity)
avconv | sox | nc
I am starting about 150 such commands on the same box at the same time.
The last nc
command sends the stream to another host. When that host dies, nc
dies but avconv
and sox
can stay alive. When I then killall sox
in this situation, avconv
stays alive.
Should there not be a sigpipe
?
When I execute the bash script manually and nc
dies, the other two processes die too. But not when I start many such scripts .
Is it possible that sigpipe
does not work when pipe buffers are full or the system is otherwise highly contended? How can I work around it?
nc
program goes away, thesox
program will only get asigpipe
when thesox
tries to write some data to the pipe. Sosox
needs to be outputting data.sox
probably buffers output, so it might need to output several thousand characters before it actually tries to push the data through the pipe. – icarus Nov 13 '16 at 15:26avconv | sox | check-data-flow-or-kill-parent | nc
– Tynix Nov 13 '16 at 17:11killall avconv
solve your problem? If avconv goes away then sox will get eof on its input, and probably will exit, then nc will get eof... – icarus Nov 13 '16 at 17:24killall is not an option because I have 150 parallel instances of it. If one instance of
– Tynix Nov 13 '16 at 19:08nc
has an issue, the other instances don't necessarily need to have an issue.avconv | sox | nc
chain. I want the chain to restart doing its work whenever there is any problem with any of the 3 processes. Unfortunately when the destination host goes down, I see many instances ofavconv
andsox
still up, althoughnc
is terminated. For that reason, my retry mechanism has no effect because some child processes are still running. – Tynix Nov 13 '16 at 19:19