Exception: SignalException

Inherits:
Exception show all
Defined in:
error.c,
error.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

Direct Known Subclasses

Interrupt

Instance Method Summary collapse

Methods inherited from Exception

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

Constructor Details

#new(sig_name) ⇒ Object #new(sig_number[, name]) ⇒ Object

Construct a new SignalException object. sig_name should be a known

signal name.


339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'signal.c', line 339

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.

Returns:



384
385
386
387
388
# File 'signal.c', line 384

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