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
72 # show that setting a trap on SIGCHLD is not disastrous.
76 trap 'echo caught a child death' SIGCHLD
78 sleep 7 & sleep 6 & sleep 5 &
80 # this will only catch the first, since there's a trap on SIGCHLD
85 # Now reset some of the signals the shell handles specially back to
86 # their default values (with or without the SIG prefix)
87 trap - SIGINT QUIT TERM