* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2011-05-15 13:37:47 +00:00
Родитель 980155686a
Коммит 29c2876d61
3 изменённых файлов: 27 добавлений и 11 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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