Exception: Interrupt

Inherits:
SignalException show all
Defined in:
error.c,
error.c

Overview

Raised when the interrupt signal is received, typically because the user has pressed 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 SignalException

#signo

Methods inherited from Exception

#==, #backtrace, #backtrace_locations, #cause, #exception, exception, #full_message, #inspect, #message, #set_backtrace, #to_s, to_tty?

Constructor Details

#initialize(*args) ⇒ Object

:nodoc:



394
395
396
397
398
399
400
401
402
# File 'signal.c', line 394

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

    args[0] = INT2FIX(SIGINT);
    args[1] = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
    return rb_call_super(2, args);
}