1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 trap 'echo aborting' 1 2 3 6 15
19 # make sure a user-specified subshell runs the exit trap, but does not
20 # inherit the exit trap from a parent shell
21 ( trap 'echo subshell exit' 0; exit 0 )
28 trap 'echo ${FUNCNAME:-$0}[$LINENO] funcdebug' DEBUG
32 trap 'echo [$LINENO] debug' DEBUG
41 trap 'echo ${FUNCNAME:-$0}[$LINENO] debug' DEBUG
66 # exit 0 in exit trap should set exit status
75 # hmmm...should this set the handling to SIG_IGN for children, too?
83 ${THIS_SH} ./trap3.sub
85 ${THIS_SH} ./trap4.sub
87 # This doesn't work right on all Unix versions
88 #${THIS_SH} ./trap5.sub
91 ${THIS_SH} ./trap6.sub
94 # show that setting a trap on SIGCHLD is not disastrous.
98 trap 'echo caught a child death' SIGCHLD
100 sleep 7 & sleep 6 & sleep 5 &
102 # this will only catch the first, since there's a trap on SIGCHLD
107 # Now reset some of the signals the shell handles specially back to
108 # their default values (with or without the SIG prefix)
109 trap - SIGINT QUIT TERM