ruby-changes:35736
From: nobu <ko1@a...>
Date: Mon, 6 Oct 2014 16:23:14 +0900 (JST)
Subject: [ruby-changes:35736] nobu:r47818 (trunk): signal.c: send signal unless handled
nobu 2014-10-06 16:23:06 +0900 (Mon, 06 Oct 2014) New Revision: 47818 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47818 Log: 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] Modified files: trunk/ChangeLog trunk/signal.c trunk/test/ruby/test_signal.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 47817) +++ ChangeLog (revision 47818) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Oct 6 16:23:30 2014 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * test/ruby/test_string.rb (test_LSHIFT_neary_long_max): enable Index: test/ruby/test_signal.rb =================================================================== --- test/ruby/test_signal.rb (revision 47817) +++ test/ruby/test_signal.rb (revision 47818) @@ -279,5 +279,12 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L279 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 Index: signal.c =================================================================== --- signal.c (revision 47817) +++ signal.c (revision 47818) @@ -357,6 +357,7 @@ ruby_default_signal(int sig) https://github.com/ruby/ruby/blob/trunk/signal.c#L357 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) https://github.com/ruby/ruby/blob/trunk/signal.c#L466 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) https://github.com/ruby/ruby/blob/trunk/signal.c#L485 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, sig https://github.com/ruby/ruby/blob/trunk/signal.c#L644 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/