Let's say there is a simple script named
#!/bin/bash echo -n 'a' | nc a.b.c.d p
action.sh here puts an
a character to
nc can hang sometimes, and I want to kill it:
$ ./action.sh ^C
This works fine, no zombies left.
When I put this into background and try to terminate it,
nc stays alive and I need to clean up manually:
& ./action.sh &  28747 & kill -15 28747 //here nc is still running! I have to find its PID and terminate it
Is there a way to ask
action.sh to terminate
nc too when it receives a termination signal?