T
Todd A. Jacobs
I'm trying to break a loop whenever CTRL-C is pressed, and find that
this doesn't work:
trap 'INT', proc {break}; count=0; while count < 10;
puts count += 1; sleep 1; end
I'm guessing it's because the loop is somehow out of scope, but I'm not
sure why.
Some minor syntax changes to trap makes it work, sort of. If I use:
trap('INT') {break}
instead, then I get a LocalJumpError. So, why does the syntax only work
one way, and what is the right way to trap the interrupt?
this doesn't work:
trap 'INT', proc {break}; count=0; while count < 10;
puts count += 1; sleep 1; end
I'm guessing it's because the loop is somehow out of scope, but I'm not
sure why.
Some minor syntax changes to trap makes it work, sort of. If I use:
trap('INT') {break}
instead, then I get a LocalJumpError. So, why does the syntax only work
one way, and what is the right way to trap the interrupt?