diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2007-11-12 13:06:02 -0800 |
commit | b7fc9e0f6d6105ba2203f219743d4b269415e84b (patch) | |
tree | ef6586dfc62798c2b17487b443864699aca55f31 /tests/trap.tests | |
download | vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.tar.gz vyatta-bash-b7fc9e0f6d6105ba2203f219743d4b269415e84b.zip |
initial import from bash_3.1dfsg.orig.tar.gz
Diffstat (limited to 'tests/trap.tests')
-rw-r--r-- | tests/trap.tests | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/trap.tests b/tests/trap.tests new file mode 100644 index 0000000..9aac725 --- /dev/null +++ b/tests/trap.tests @@ -0,0 +1,86 @@ +# test the trap code + +trap 'echo exiting' 0 +trap 'echo aborting' 1 2 3 6 15 + +# make sure a user-specified subshell runs the exit trap, but does not +# inherit the exit trap from a parent shell +( trap 'echo subshell exit' 0; exit 0 ) +( exit 0 ) + +trap + +func() +{ + trap 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG + echo funcdebug line +} + +trap 'echo [$LINENO] debug' DEBUG +echo debug line + +trap + +func + +trap + +trap 'echo ${FUNCNAME:-$0}[$LINENO] debug' DEBUG +func2() +{ + echo func2debug line +} +declare -ft func2 +func2 + +unset -f func2 + +trap '' DEBUG + +trap + +trap - debug + +trap + +trap - HUP +trap hup +trap '' INT +trap '' int + +trap + +# exit 0 in exit trap should set exit status +( +set -e +trap 'exit 0' EXIT +false +echo bad +) +echo $? + +# hmmm...should this set the handling to SIG_IGN for children, too? +trap '' USR2 +./trap1.sub + +# test ERR trap +./trap2.sub + +# +# show that setting a trap on SIGCHLD is not disastrous. +# +set -o monitor + +trap 'echo caught a child death' SIGCHLD + +sleep 7 & sleep 6 & sleep 5 & + +wait + +trap -p SIGCHLD + +# Now reset some of the signals the shell handles specially back to +# their default values (with or without the SIG prefix) +trap - SIGINT QUIT TERM + +trap |