Exception: Interrupt

Inherits:
SignalException show all
Defined in:
error.c

Overview

Raised with the interrupt signal is received, typically because the user pressed on Control-C (on most posix platforms). As such, it is a subclass of SignalException.

begin
  puts "Press ctrl-C when you get bored"
  loop {}
rescue Interrupt => e
  puts "Note: You will typically use Signal.trap instead."
end

produces:

Press ctrl-C when you get bored

then waits until it is interrupted with Control-C and then prints:

Note: You will typically use Signal.trap instead.

Instance Method Summary collapse

Methods inherited from Exception

#==, #backtrace, #exception, exception, #inspect, #message, #set_backtrace, #to_s

Constructor Details

#initializeObject

:nodoc:



# File 'signal.c'

static VALUE
interrupt_init(int argc, VALUE *argv, VALUE self)
{
    VALUE args[2];

    args[0] = INT2FIX(SIGINT);
    rb_scan_args(argc, argv, "01", &args[1]);
    return rb_call_super(2, args);
}