1 2 3 4 5 6 7 8 9 10 11
#!/bin/bash # trapchild sleep 120 & pid="$!" trap 'echo I am going down, so killing off my processes..; kill $pid; exit' SIGHUP SIGINT SIGQUIT SIGTERM wait