Berger, Daniel
12/8/2005 7:57:00 PM
William E. Rubin wrote:
> How does one detect Control-C?
trap("INT"){ ... }
>
> I know that it raises an Interrupt, but there are other things that are
> also Interrupts (such as Timeout::Error). The documentation at
> ruby-doc.org doesn't list any details of class Interrupt, and the
> "Programming Ruby" book at ruby-lang.org doesn't even seem to mention
> that class Interrupt exists.
>
> Thanks.
Interrupt is a subclass of SignalException (which is a subclass of Exception).
As far as I can tell (based on what I see in eval.c) it's only used for
trapping Unix signals*, i.e. whatever's in your signal.h file.
Also, take a look at the Signal module.
Regards,
Dan
* Works on Windows too, though the implementation is different, and likely
requires a separate sleeper thread.