summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-21 02:03:34 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-21 02:03:34 (GMT)
commite41fde8b776e299342543a85f315646a25bec194 (patch)
tree1fe606167c6f6fbd3181431f52c0d978ea9a38dc /signal.c
parenta718be06fac884b62435a7fc9bb251131163c06e (diff)
signal.c: EINVAL is a failure
* signal.c (ruby_signal): although "EINVAL from sigaction(2) is not a bug", but even it is a failure. pointed at toRuby/guRuby in RubyHiroba. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/signal.c b/signal.c
index 0757385..296afdd 100644
--- a/signal.c
+++ b/signal.c
@@ -258,6 +258,18 @@ ruby_signal_name(int no)
return signo2signm(no);
}
+static VALUE
+rb_signo2signm(int signo)
+{
+ const char *const signm = signo2signm(signo);
+ if (signm) {
+ return rb_sprintf("SIG%s", signm);
+ }
+ else {
+ return rb_sprintf("SIG%u", signo);
+ }
+}
+
/*
* call-seq:
* SignalException.new(sig_name) -> signal_exception
@@ -290,13 +302,7 @@ esignal_init(int argc, VALUE *argv, VALUE self)
sig = argv[1];
}
else {
- signm = signo2signm(signo);
- if (signm) {
- sig = rb_sprintf("SIG%s", signm);
- }
- else {
- sig = rb_sprintf("SIG%u", signo);
- }
+ sig = rb_signo2signm(signo);
}
}
else {
@@ -600,8 +606,12 @@ ruby_signal(int signum, sighandler_t handler)
}
(void)VALGRIND_MAKE_MEM_DEFINED(&old, sizeof(old));
if (sigaction(signum, &sigact, &old) < 0) {
- if (errno != 0 && errno != EINVAL) {
- rb_bug_errno("sigaction", errno);
+ int e = errno;
+ if (e == EINVAL) {
+ rb_syserr_fail_str(e, rb_signo2signm(signum));
+ }
+ else if (e != 0) {
+ rb_bug_errno("sigaction", e);
}
}
if (old.sa_flags & SA_SIGINFO)