Killing Child Processes on Exitsuggest change
Trap expressions don’t have to be individual functions or programs, they can be more complex expressions as well.
jobs -p and
kill, we can kill all spawned child processes of the shell on exit:
trap 'jobs -p | xargs kill' EXIT
Table Of Contents