Re: Control-C behavior
- From: "uymqlp502@xxxxxxxxxxxxxx" <uymqlp502@xxxxxxxxxxxxxx>
- Date: 16 Jan 2007 15:28:04 -0800
Brian Mac wrote:
hi,
look at using a trap..
trap 'exit 11' 2
for loop
trap 2
the first trap changes the default behaviour of the control-c to an
exit - you can set whatever value you want but i chose 11. put in your
for loop and then set the default trap value for a signal 2. you can
verify this by checking the exit status after running the break - echo
$?. it should be 11 (or whatever you chose to set it to)
That didn't seem to work for me, but simply putting the following at
the top of the script seems to work:
trap 'exit' INT TERM
hope this helps,
brian
uymqlp502@xxxxxxxxxxxxxx wrote:
I have a bash script with a for loop that starts other bash scripts (in
the foreground). When I hit Control-C, I want the top-level script to
terminate, but depending on the timing, sometimes one of the sub
scripts terminates instead. How can I ensure that the whole enchilada
will terminate? Thanks.
.
- References:
- Control-C behavior
- From: uymqlp502@xxxxxxxxxxxxxx
- Re: Control-C behavior
- From: Brian Mac
- Control-C behavior
- Prev by Date: Re: I will like to know how to add a word to the beginning of a line and the end of this same line.
- Next by Date: `builtin test -a foo` VS `builtin test ! -a foo`
- Previous by thread: Re: Control-C behavior
- Next by thread: Re: Control-C behavior
- Index(es):
Relevant Pages
|