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.


Linux

28 Words

2011-01-07 18:43 +0000