Imported from ../bash-2.01.tar.gz.
[platform/upstream/bash.git] / tests / trap.tests
1 # test the trap code
2
3 trap 'echo exiting' 0
4 trap 'echo aborting' 1 2 3 6 15
5
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 )
9 ( exit 0 )
10
11 trap
12
13 func()
14 {
15         trap 'echo [$LINENO] funcdebug' DEBUG
16         echo funcdebug line
17 }
18
19 trap 'echo [$LINENO] debug' DEBUG
20 echo debug line
21
22 trap
23
24 func
25
26 trap
27
28 trap '' DEBUG
29
30 trap
31
32 trap - debug
33
34 trap
35
36 trap - HUP
37 trap hup
38 trap '' INT
39 trap '' int
40
41 trap
42
43 # hmmm...should this set the handling to SIG_IGN for children, too?
44 trap '' USR2
45 ./trap.sub1
46
47 #
48 # show that setting a trap on SIGCHLD is not disastrous.
49 #
50 set -o monitor
51
52 trap 'echo caught a child death' SIGCHLD
53
54 sleep 7 & sleep 6 & sleep 5 &
55
56 wait
57
58 trap -p SIGCHLD