Skip to main content
2 of 2
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/

The following will kill the process group when the nc ends

#!/bin/sh
avconv x y z | sox a b c | { nc somewhere port ; pkill -g 0 ; }

Depending on how this gets started you might need to use a utility like setsid to restrict the things which are in the group. You could also replace -g 0 with -P $$. This works by the shell running the pkill command after the nc finishes.

See also Kill all descendant processes

icarus
  • 19.1k
  • 1
  • 42
  • 57