123456789_123456789_123456789_123456789_123456789_

Exception: SignalException

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Exception
Instance Chain:
self, ::Exception
Inherits: Exception
Defined in: error.c,
error.c,
signal.c

Overview

Raised when a signal is received.

begin
  Process.kill('HUP',Process.pid)
  sleep # wait for receiver to handle signal sent by Process.kill
rescue SignalException => e
  puts "received Exception #{e}"
end

produces:

received Exception SIGHUP

Class Attribute Summary

::Exception - Inherited

.to_tty?

Returns true if exception messages will be sent to a tty.

Class Method Summary

::Exception - Inherited

.exception

With no argument, or if the argument is the same as the receiver, return the receiver.

.new

Construct a new ::Exception object, optionally passing in a message.

Instance Method Summary

::Exception - Inherited

#==

Equality—If obj is not an ::Exception, returns false.

#backtrace

Returns any backtrace associated with the exception.

#backtrace_locations

Returns any backtrace associated with the exception.

#cause

Returns the previous exception ($!) at the time this exception was raised.

#exception

With no argument, or if the argument is the same as the receiver, return the receiver.

#full_message

Returns formatted string of exception.

#inspect

Return this exception's class name and message.

#message

Returns the result of invoking exception.to_s.

#set_backtrace

Sets the backtrace information associated with exc.

#to_s

Returns exception's message (or the name of the exception if no message is set).

Constructor Details

.new(sig_name) ⇒ signal_exception .new(sig_number[, name]) ⇒ signal_exception

Construct a new SignalException object. sig_name should be a known signal name.

[ GitHub ]

  
# File 'signal.c', line 336

static VALUE
esignal_init(int argc, VALUE *argv, VALUE self)
{
    int argnum = 1;
    VALUE sig = Qnil;
    int signo;

    if (argc > 0) {
	sig = rb_check_to_integer(argv[0], "to_int");
	if (!NIL_P(sig)) argnum = 2;
	else sig = argv[0];
    }
    rb_check_arity(argc, 1, argnum);
    if (argnum == 2) {
	signo = NUM2INT(sig);
	if (signo < 0 || signo > NSIG) {
	    rb_raise(rb_eArgError, "invalid signal number (%d)", signo);
	}
	if (argc > 1) {
	    sig = argv[1];
	}
	else {
	    sig = rb_signo2signm(signo);
	}
    }
    else {
	int prefix;
	signo = signm2signo(&sig, FALSE, FALSE, &prefix);
	if (prefix != signame_prefix_len) {
	    sig = rb_str_append(rb_str_new_cstr("SIG"), sig);
	}
    }
    rb_call_super(1, &sig);
    rb_ivar_set(self, id_signo, INT2NUM(signo));

    return self;
}

Instance Method Details

#signoNumeric

Returns a signal number.

[ GitHub ]

  
# File 'signal.c', line 381

static VALUE
esignal_signo(VALUE self)
{
    return rb_ivar_get(self, id_signo);
}