Last active
May 4, 2020 13:51
-
-
Save akskap/b3da0004844705db517f2b6f9890817a to your computer and use it in GitHub Desktop.
Trap handling in bash
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
function handle_exit() { | |
// Add cleanup code here | |
// for eg. rm -f "/tmp/${lock_file}.lock" | |
// exit with an appropriate status code | |
} | |
// trap <HANDLER_FXN> <LIST OF SIGNALS TO TRAP> | |
trap handle_exit 0 SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment