Exception: SignalException
Overview
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
Construct a new SignalException object.
-
#signo ⇒ Numeric
Returns a signal number.
Methods inherited from Exception
#==, #backtrace, #backtrace_locations, #cause, #exception, exception, #inspect, #message, #set_backtrace, #to_s
Constructor Details
#new(sig_name) ⇒ Object #new(sig_number[, name]) ⇒ Object
Construct a new SignalException object. sig_name
should be a known
signal name.
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'signal.c', line 287
static VALUE
esignal_init(int argc, VALUE *argv, VALUE self)
{
int argnum = 1;
VALUE sig = Qnil;
int signo;
const char *signm;
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 len = sizeof(signame_prefix);
if (SYMBOL_P(sig)) sig = rb_sym2str(sig); else StringValue(sig);
signm = RSTRING_PTR(sig);
if (strncmp(signm, signame_prefix, len) == 0) {
signm += len;
len = 0;
}
signo = signm2signo(signm);
if (!signo) {
rb_raise(rb_eArgError, "unsupported name `%.*s%"PRIsVALUE"'",
len, signame_prefix, sig);
}
sig = rb_sprintf("SIG%s", signm);
}
rb_call_super(1, &sig);
rb_ivar_set(self, id_signo, INT2NUM(signo));
return self;
}
|
Instance Method Details
#signo ⇒ Numeric
Returns a signal number.
341 342 343 344 345 |
# File 'signal.c', line 341
static VALUE
esignal_signo(VALUE self)
{
return rb_ivar_get(self, id_signo);
}
|