Bash: Stop all sub-processes in a bash script.

trap "ps -o pid= --ppid $$ | xargs kill" SIGINT SIGTERM

Be sure that the script itself didn't finish. If so, end the script with a wait command.

No votes yet