mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c7b2577178
commit
e8bd56f5c3
2 changed files with 15 additions and 2 deletions
9
signal.c
9
signal.c
|
@ -1089,8 +1089,13 @@ trap(int sig, sighandler_t func, VALUE command)
|
||||||
* atomically. In current implementation, we only need to don't call
|
* atomically. In current implementation, we only need to don't call
|
||||||
* RUBY_VM_CHECK_INTS().
|
* RUBY_VM_CHECK_INTS().
|
||||||
*/
|
*/
|
||||||
oldfunc = ruby_signal(sig, func);
|
if (sig == 0) {
|
||||||
if (oldfunc == SIG_ERR) rb_sys_fail_str(rb_signo2signm(sig));
|
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;
|
oldcmd = vm->trap_list[sig].cmd;
|
||||||
switch (oldcmd) {
|
switch (oldcmd) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -177,6 +177,14 @@ class TestSignal < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
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
|
def test_kill_immediately_before_termination
|
||||||
Signal.list[sig = "USR1"] or sig = "INT"
|
Signal.list[sig = "USR1"] or sig = "INT"
|
||||||
assert_in_out_err(["-e", <<-"end;"], "", %w"foo")
|
assert_in_out_err(["-e", <<-"end;"], "", %w"foo")
|
||||||
|
|
Loading…
Reference in a new issue