* 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:
parent
980155686a
commit
29c2876d61
@ -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>
|
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
|
* cont.c (cont_init): clear macihne_stack_start/end of saved thread to
|
||||||
|
7
signal.c
7
signal.c
@ -359,6 +359,7 @@ rb_f_kill(int argc, VALUE *argv)
|
|||||||
int negative = 0;
|
int negative = 0;
|
||||||
int sig;
|
int sig;
|
||||||
int i;
|
int i;
|
||||||
|
volatile VALUE str;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
@ -376,11 +377,11 @@ rb_f_kill(int argc, VALUE *argv)
|
|||||||
|
|
||||||
case T_STRING:
|
case T_STRING:
|
||||||
s = RSTRING_PTR(argv[0]);
|
s = RSTRING_PTR(argv[0]);
|
||||||
|
str_signal:
|
||||||
if (s[0] == '-') {
|
if (s[0] == '-') {
|
||||||
negative++;
|
negative++;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
str_signal:
|
|
||||||
if (strncmp("SIG", s, 3) == 0)
|
if (strncmp("SIG", s, 3) == 0)
|
||||||
s += 3;
|
s += 3;
|
||||||
if((sig = signm2signo(s)) == 0)
|
if((sig = signm2signo(s)) == 0)
|
||||||
@ -391,9 +392,6 @@ rb_f_kill(int argc, VALUE *argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
|
||||||
VALUE str;
|
|
||||||
|
|
||||||
str = rb_check_string_type(argv[0]);
|
str = rb_check_string_type(argv[0]);
|
||||||
if (!NIL_P(str)) {
|
if (!NIL_P(str)) {
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
@ -401,7 +399,6 @@ rb_f_kill(int argc, VALUE *argv)
|
|||||||
}
|
}
|
||||||
rb_raise(rb_eArgError, "bad signal type %s",
|
rb_raise(rb_eArgError, "bad signal type %s",
|
||||||
rb_obj_classname(argv[0]));
|
rb_obj_classname(argv[0]));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,18 @@ class TestSignal < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
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
|
def test_exit_action
|
||||||
return unless have_fork? # skip this test
|
return unless have_fork? # skip this test
|
||||||
begin
|
begin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user