diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-21 14:17:10 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-21 14:17:10 +0000 |
commit | 5de144f3a56eaee430680bc83d80a8a3e8134fdc (patch) | |
tree | 7973405bd80bd51445a82f37bb45b50fa72baad9 | |
parent | 042594bb502f4199a3e4e676c01c8375f6cdcb48 (diff) | |
download | ruby-5de144f3a56eaee430680bc83d80a8a3e8134fdc.tar.gz |
thread.c: fix deadlock
* thread.c (ruby_kill): get rid of deadlock on signal 0.
[ruby-dev:47182] [Bug #8137]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_signal.rb | 8 | ||||
-rw-r--r-- | thread.c | 5 |
3 files changed, 15 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Thu Mar 21 23:17:08 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * thread.c (ruby_kill): get rid of deadlock on signal 0. + [ruby-dev:47182] [Bug #8137] + Thu Mar 21 23:14:15 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * include/ruby/ruby.h (RB_UNUSED_VAR): move code from diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index c7cce9a9d7..fa385c0312 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -283,7 +283,13 @@ EOS # This ugly workaround was introduced to don't break # compatibility against silly example codes. assert_raise(SignalException) { - Process.kill('HUP',Process.pid) + Process.kill('HUP', Process.pid) + } + bug8137 = '[ruby-dev:47182] [Bug #8137]' + assert_nothing_raised(bug8137) { + Timeout.timeout(1) { + Process.kill(0, Process.pid) + } } end end @@ -5214,14 +5214,15 @@ ruby_kill(rb_pid_t pid, int sig) * When target pid is self, many caller assume signal will be * delivered immediately and synchronously. */ - if ((th == vm->main_thread) && (pid == getpid())) { + if ((sig != 0) && (th == vm->main_thread) && (pid == getpid())) { GVL_UNLOCK_BEGIN(); native_mutex_lock(&th->interrupt_lock); err = kill(pid, sig); native_cond_wait(&th->interrupt_cond, &th->interrupt_lock); native_mutex_unlock(&th->interrupt_lock); GVL_UNLOCK_END(); - } else { + } + else { err = kill(pid, sig); } if (err < 0) |