diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | signal.c | 19 | ||||
-rw-r--r-- | test/ruby/test_signal.rb | 12 |
3 files changed, 27 insertions, 11 deletions
@@ -1,3 +1,10 @@ +Sun May 15 22:26:39 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com> + + * signal.c (rb_f_kill): accept '-SIGXXX' style signal with Symbol or + implicit convertion with #to_str. [ruby-dev:43169] fixes #4362 + * test/ruby/test_signal.rb (test_signal_process_group): add a test + for send signal to process group. + Sun May 15 21:22:35 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com> * cont.c (cont_init): clear macihne_stack_start/end of saved thread to @@ -359,6 +359,7 @@ rb_f_kill(int argc, VALUE *argv) int negative = 0; int sig; int i; + volatile VALUE str; const char *s; rb_secure(2); @@ -376,11 +377,11 @@ rb_f_kill(int argc, VALUE *argv) case T_STRING: s = RSTRING_PTR(argv[0]); + str_signal: if (s[0] == '-') { negative++; s++; } - str_signal: if (strncmp("SIG", s, 3) == 0) s += 3; if((sig = signm2signo(s)) == 0) @@ -391,17 +392,13 @@ rb_f_kill(int argc, VALUE *argv) break; default: - { - VALUE str; - - str = rb_check_string_type(argv[0]); - if (!NIL_P(str)) { - s = RSTRING_PTR(str); - goto str_signal; - } - rb_raise(rb_eArgError, "bad signal type %s", - rb_obj_classname(argv[0])); + str = rb_check_string_type(argv[0]); + if (!NIL_P(str)) { + s = RSTRING_PTR(str); + goto str_signal; } + rb_raise(rb_eArgError, "bad signal type %s", + rb_obj_classname(argv[0])); break; } diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index 0098ccc539..2b2d88b06f 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -36,6 +36,18 @@ class TestSignal < Test::Unit::TestCase end end + def test_signal_process_group + return unless Process.respond_to?(:kill) + bug4362 = '[ruby-dev:43169]' + assert_nothing_raised(bug4362) do + pid = Process.spawn(EnvUtil.rubybin, '-e', '"sleep 10"', :pgroup => true) + Process.kill(:"-TERM", pid) + Process.waitpid(pid) + assert_equal(true, $?.signaled?) + assert_equal(Signal.list["TERM"], $?.termsig) + end + end + def test_exit_action return unless have_fork? # skip this test begin |