Last active
October 11, 2020 08:36
-
-
Save iinm/24a8b8011fc23079310baae130d61d36 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -eu | |
on_exit() { | |
exit_status="$?" | |
echo "--- on_exit: exit_status=$exit_status" | |
return "$exit_status" | |
} | |
on_cancel() { | |
echo "--- on_cancel:" | |
trap -- EXIT | |
trap -- TERM | |
kill -s TERM $$ | |
} | |
trap 'on_exit' EXIT | |
trap 'on_cancel' HUP INT QUIT TERM | |
"$@" & | |
wait "$(jobs -p)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment