summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-10 05:48:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-04-10 05:48:43 +0000
commit7194267b3bdf68ad75bd6bee8e7c6377f7b0ea2f (patch)
tree6dcd08ef584fc777cf34517136d5ce3948840e45 /signal.c
parentbe72d9a5da9be284d2bdb8047e50f14e014b7835 (diff)
2000-04-10
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/signal.c b/signal.c
index d0b0981793..9be0d48ee5 100644
--- a/signal.c
+++ b/signal.c
@@ -429,6 +429,7 @@ trap(arg)
RETSIGTYPE (*func)();
VALUE command, old;
int sig;
+ char *s;
func = sighandle;
command = arg->cmd;
@@ -466,18 +467,27 @@ trap(arg)
command = 0;
}
- if (TYPE(arg->sig) == T_STRING) {
- char *s = RSTRING(arg->sig)->ptr;
+ switch (TYPE(arg->sig)) {
+ case T_FIXNUM:
+ sig = NUM2INT(arg->sig);
+ break;
+
+ case T_SYMBOL:
+ s = rb_id2name(SYM2ID(arg->sig));
+ if (!s) rb_raise(rb_eArgError, "bad signal");
+ goto str_signal;
+
+ case T_STRING:
+ s = RSTRING(arg->sig)->ptr;
+ str_signal:
if (strncmp("SIG", s, 3) == 0)
s += 3;
sig = signm2signo(s);
if (sig == 0 && strcmp(s, "EXIT") != 0)
rb_raise(rb_eArgError, "invalid signal SIG%s", s);
}
- else {
- sig = NUM2INT(arg->sig);
- }
+
if (sig < 0 || sig > NSIG) {
rb_raise(rb_eArgError, "invalid signal number (%d)", sig);
}