ruby-changes:35587
From: nobu <ko1@a...>
Date: Sun, 21 Sep 2014 14:10:33 +0900 (JST)
Subject: [ruby-changes:35587] nobu:r47669 (trunk): signal.c: SIGEXIT is not a system signal
nobu 2014-09-21 14:10:14 +0900 (Sun, 21 Sep 2014) New Revision: 47669 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47669 Log: signal.c: SIGEXIT is not a system signal * signal.c (trap): SIGEXIT is not a system signal and is dealt with internally, so it should not try to register the system signal handler by sigaction. Modified files: trunk/signal.c trunk/test/ruby/test_signal.rb Index: test/ruby/test_signal.rb =================================================================== --- test/ruby/test_signal.rb (revision 47668) +++ test/ruby/test_signal.rb (revision 47669) @@ -177,6 +177,14 @@ class TestSignal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L177 end end + def test_sigexit + assert_in_out_err([], 'Signal.trap(:EXIT) {print "OK"}', ["OK"]) + assert_in_out_err([], 'Signal.trap("EXIT") {print "OK"}', ["OK"]) + assert_in_out_err([], 'Signal.trap(:SIGEXIT) {print "OK"}', ["OK"]) + assert_in_out_err([], 'Signal.trap("SIGEXIT") {print "OK"}', ["OK"]) + assert_in_out_err([], 'Signal.trap(0) {print "OK"}', ["OK"]) + end + def test_kill_immediately_before_termination Signal.list[sig = "USR1"] or sig = "INT" assert_in_out_err(["-e", <<-"end;"], "", %w"foo") Index: signal.c =================================================================== --- signal.c (revision 47668) +++ signal.c (revision 47669) @@ -1089,8 +1089,13 @@ trap(int sig, sighandler_t func, VALUE c https://github.com/ruby/ruby/blob/trunk/signal.c#L1089 * atomically. In current implementation, we only need to don't call * RUBY_VM_CHECK_INTS(). */ - oldfunc = ruby_signal(sig, func); - if (oldfunc == SIG_ERR) rb_sys_fail_str(rb_signo2signm(sig)); + if (sig == 0) { + oldfunc = SIG_ERR; + } + else { + oldfunc = ruby_signal(sig, func); + if (oldfunc == SIG_ERR) rb_sys_fail_str(rb_signo2signm(sig)); + } oldcmd = vm->trap_list[sig].cmd; switch (oldcmd) { case 0: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/