I have the following in bash:
foo | bar
I want foo to die when the script is terminated (using a TERM signal). Unfortunately, none of them dies. I tried this:
exec foo | bar
This achieved absolutely nothing. Then I tried this:
function run() {
"$@" &
pid=$!
trap "kill $pid" EXIT
wait
}
run foo | bar
Again, nothing. Now I have one more process, and none of them dies when I terminate the parent.