Last active
February 17, 2017 19:53
-
-
Save jotafeldmann/804d99f88b15d95effb5d984332976fe to your computer and use it in GitHub Desktop.
How to get EXIT SIGNAL in bash for TRAPS
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
#!/bin/bash | |
trap_with_arg() { | |
func="$1" ; shift | |
for sig ; do | |
trap "$func $sig" "$sig" | |
done | |
} | |
func_trap() { | |
echo Trapped: $1 | |
} | |
trap_with_arg func_trap SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGABRT SIGEMT SIGFPE SIGKILL SIGBUS SIGSEGV SIGSYS SIGPIPE SIGALRM SIGTERM SIGURG SIGSTOP SIGTSTP SIGCONT SIGCHLD SIGTTIN SIGTTOU SIGIO SIGXCPU SIGXFSZ SIGVTALRM SIGPROF SIGWINCH SIGINFO SIGUSR1 SIGUSR2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment