diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-06 07:23:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-06 07:23:06 +0000 |
commit | 998befe8e650006507611ede33205f7e225197b6 (patch) | |
tree | d83ec44eb8a3e1ca678217ff52c5a0e950c3624e | |
parent | 559154310fea589dbd6e718f4c87fef9c08d2459 (diff) | |
download | ruby-998befe8e650006507611ede33205f7e225197b6.tar.gz |
signal.c: send signal unless handled
* signal.c (rb_f_kill): should not ignore signal unless the
default handler is registered. [ruby-dev:48592] [Bug #9820]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | signal.c | 15 | ||||
-rw-r--r-- | test/ruby/test_signal.rb | 7 |
3 files changed, 24 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Mon Oct 6 16:23:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * signal.c (rb_f_kill): should not ignore signal unless the + default handler is registered. [ruby-dev:48592] [Bug #9820] + Mon Oct 6 16:07:11 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * test/ruby/test_string.rb (test_LSHIFT_neary_long_max): enable @@ -357,6 +357,7 @@ ruby_default_signal(int sig) raise(sig); } +static RETSIGTYPE sighandler(int sig); static int signal_ignored(int sig); static void signal_enque(int sig); @@ -465,6 +466,7 @@ rb_f_kill(int argc, const VALUE *argv) rb_pid_t pid = NUM2PIDT(argv[i]); if ((sig != 0) && (self != -1) && (pid == self)) { + int t; /* * When target pid is self, many caller assume signal will be * delivered immediately and synchronously. @@ -483,7 +485,11 @@ rb_f_kill(int argc, const VALUE *argv) ruby_kill(pid, sig); break; default: - if (signal_ignored(sig)) break; + t = signal_ignored(sig); + if (t) { + if (t < 0) ruby_kill(pid, sig); + break; + } signal_enque(sig); wakeup = 1; } @@ -638,16 +644,19 @@ ruby_nativethread_signal(int signum, sighandler_t handler) static int signal_ignored(int sig) { + sighandler_t func; #ifdef POSIX_SIGNAL struct sigaction old; (void)VALGRIND_MAKE_MEM_DEFINED(&old, sizeof(old)); if (sigaction(sig, NULL, &old) < 0) return FALSE; - return old.sa_handler == SIG_IGN; + func = old.sa_handler; #else sighandler_t old = signal(sig, SIG_DFL); signal(sig, old); - return old == SIG_IGN; + func = old; #endif + if (func == SIG_IGN) return 1; + return func == sighandler ? 0 : -1; } static void diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index 93a497a831..32068a407a 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -279,5 +279,12 @@ EOS Process.kill(:INT, $$) end end; + + if trap = Signal.list['TRAP'] + bug9820 = '[ruby-dev:48592] [Bug #9820]' + status = assert_in_out_err(['-e', 'Process.kill(:TRAP, $$)']) + assert_predicate(status, :signaled?, bug9820) + assert_equal(trap, status.termsig, bug9820) + end end if Process.respond_to?(:kill) end |