4
trap 'echo aborting' 1 2 3 6 15
6
# make sure a user-specified subshell runs the exit trap, but does not
7
# inherit the exit trap from a parent shell
8
( trap 'echo subshell exit' 0; exit 0 )
15
trap 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG
19
trap 'echo [$LINENO] debug' DEBUG
28
trap 'echo ${FUNCNAME:-$0}[$LINENO] debug' DEBUG
53
# exit 0 in exit trap should set exit status
62
# hmmm...should this set the handling to SIG_IGN for children, too?
69
${THIS_SH} ./trap3.sub
71
${THIS_SH} ./trap4.sub
73
# This doesn't work right on all Unix versions
74
#${THIS_SH} ./trap5.sub
77
# show that setting a trap on SIGCHLD is not disastrous.
81
trap 'echo caught a child death' SIGCHLD
83
sleep 7 & sleep 6 & sleep 5 &
85
# this will only catch the first, since there's a trap on SIGCHLD
90
# Now reset some of the signals the shell handles specially back to
91
# their default values (with or without the SIG prefix)
92
trap - SIGINT QUIT TERM