Killing Child Processes on Exit

suggest change

Trap expressions don’t have to be individual functions or programs, they can be more complex expressions as well.

By combining jobs -p and kill, we can kill all spawned child processes of the shell on exit:

trap 'jobs -p | xargs kill' EXIT

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Using trap to react to signals and system events:
*Killing Child Processes on Exit

Table Of Contents