]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/trap.tests
Imported from ../bash-2.05.tar.gz.
[thirdparty/bash.git] / tests / trap.tests
CommitLineData
d166f048
JA
1# test the trap code
2
3trap 'echo exiting' 0
4trap '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
11trap
12
13func()
14{
15 trap 'echo [$LINENO] funcdebug' DEBUG
16 echo funcdebug line
17}
18
19trap 'echo [$LINENO] debug' DEBUG
20echo debug line
21
22trap
23
24func
25
26trap
27
28trap '' DEBUG
29
30trap
31
32trap - debug
33
34trap
35
36trap - HUP
37trap hup
38trap '' INT
39trap '' int
40
41trap
42
28ef6c31
JA
43# exit 0 in exit trap should set exit status
44(
45set -e
46trap 'exit 0' EXIT
47false
48echo bad
49)
50echo $?
51
d166f048
JA
52# hmmm...should this set the handling to SIG_IGN for children, too?
53trap '' USR2
cce855bc 54./trap1.sub
d166f048
JA
55
56#
57# show that setting a trap on SIGCHLD is not disastrous.
58#
59set -o monitor
60
61trap 'echo caught a child death' SIGCHLD
62
63sleep 7 & sleep 6 & sleep 5 &
64
65wait
66
67trap -p SIGCHLD
cce855bc
JA
68
69# Now reset some of the signals the shell handles specially back to
70# their default values (with or without the SIG prefix)
71trap SIGINT QUIT TERM
72
73trap