Re: Control-C behavior
Brian Mac wrote:
look at using a trap..
trap 'exit 11' 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,
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.
- 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