bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why must 'EXIT' trap be defined before other traps?


From: Tom Rodman
Subject: why must 'EXIT' trap be defined before other traps?
Date: Fri, 28 Dec 2001 19:41:07 GMT

>From trial and error I have concluded that you need to 
set the EXIT trap first before defining your other
traps.  Is this by design, if so why?

thanks in advance,
Tom Rodman
--v-v------------------C-U-T---H-E-R-E-------------------------v-v--
> 13:30:31 Fri Dec 28    /adm/bin/sys/s
> 1047 1 olive rodmant > cat ./trap_tests2
#! /bin/bash

trap 'echo got pseudo signal "EXIT"' EXIT
trap 'echo got SIGTERM; exit 1' SIGTERM

kill -SIGTERM $$
> 13:30:39 Fri Dec 28    /adm/bin/sys/s
> 1048 1 olive rodmant > ./trap_tests2
got SIGTERM
got pseudo signal EXIT
> 13:31:02 Fri Dec 28    /adm/bin/sys/s
> 1049 1 olive rodmant > cat ./trap_tests3
#! /bin/bash

trap 'echo got SIGTERM; exit 1' SIGTERM
trap 'echo got pseudo signal "EXIT"' EXIT

kill -SIGTERM $$
> 13:31:13 Fri Dec 28    /adm/bin/sys/s
> 1050 1 olive rodmant > ./trap_tests3
got pseudo signal EXIT
Terminated
> 13:31:16 Fri Dec 28    /adm/bin/sys/s
> 1051 1 olive rodmant > echo $BASH_VERSION
2.05.8(1)-release
> 13:32:42 Fri Dec 28    /adm/bin/sys/s
> 1052 1 olive rodmant > uname -a
Linux olive.pounder.sol.net 2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown



reply via email to

[Prev in Thread] Current Thread [Next in Thread]