Created
December 13, 2018 18:01
-
-
Save theneubeck/cabecab14b1fd95fddb2d2b489d2e174 to your computer and use it in GitHub Desktop.
wait-and-kill-subprocesses (on ctrl+c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Hej" | |
function cleanup { | |
kill $pid1 | |
kill $pid2 | |
exit | |
} | |
trap cleanup SIGHUP SIGINT SIGTERM | |
sleep 100 & | |
pid1=$! | |
sleep 200 & | |
pid2=$! | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment