summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-12 04:52:25 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-12 04:52:25 +0000
commit6c3f1461cd8052486f8e124f8f899447f653505b (patch)
treef302d31ad61acb16aece3788f803559c771e3348
parenta57d295e36980fe7667f5557c4741339d7684fdc (diff)
remove ruby_kill() introduced for [Bug #7951].
* thread.c (rbuy_kill): removed. This function is used with SIGSEGV, SIGBUS, SIGKILL, SIGILL, SIGFPE and SIGSTOP and these signals are affect immediately. So that `kill(2)' is enough for them. * signal.c (rb_f_kill): ditto. * vm_core.h (rb_thread_t::interrupt_cond): removed because only `ruby_kill()' uses this field. * test/ruby/test_signal.rb: Without this patch sending SIGSTOP to own process wait another interrupt even if another process sends SIGCONT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h1
-rw-r--r--signal.c2
-rw-r--r--test/ruby/test_signal.rb14
-rw-r--r--thread.c28
-rw-r--r--vm_core.h1
5 files changed, 15 insertions, 31 deletions
diff --git a/internal.h b/internal.h
index cc1d975..45d1426 100644
--- a/internal.h
+++ b/internal.h
@@ -1674,7 +1674,6 @@ int rb_thread_to_be_killed(VALUE thread);
void rb_mutex_allow_trap(VALUE self, int val);
VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
VALUE rb_mutex_owned_p(VALUE self);
-void ruby_kill(rb_pid_t pid, int sig);
/* thread_pthread.c, thread_win32.c */
void Init_native_thread(void);
diff --git a/signal.c b/signal.c
index 16c03e7..7baf742 100644
--- a/signal.c
+++ b/signal.c
@@ -495,7 +495,7 @@ rb_f_kill(int argc, const VALUE *argv)
#ifdef SIGSTOP
case SIGSTOP:
#endif
- ruby_kill(pid, sig);
+ kill(pid, sig);
break;
default:
t = signal_ignored(sig);
diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb
index c48a4ad..2d98b0b 100644
--- a/test/ruby/test_signal.rb
+++ b/test/ruby/test_signal.rb
@@ -307,4 +307,18 @@ EOS
b = Signal.list.keys.map(&:object_id).sort
assert_equal a, b
end
+
+ def test_self_stop
+ assert_ruby_status([], <<-'end;')
+ begin
+ fork{
+ sleep 1
+ Process.kill(:CONT, Process.ppid)
+ }
+ Process.kill(:STOP, Process.pid)
+ rescue NotImplementedError
+ # ok
+ end
+ end;
+ end
end
diff --git a/thread.c b/thread.c
index 74cdf4f..b05e721 100644
--- a/thread.c
+++ b/thread.c
@@ -425,7 +425,6 @@ rb_threadptr_interrupt_common(rb_thread_t *th, int trap)
else {
/* none */
}
- native_cond_signal(&th->interrupt_cond);
native_mutex_unlock(&th->interrupt_lock);
}
@@ -549,7 +548,6 @@ thread_cleanup_func(void *th_ptr, int atfork)
return;
native_mutex_destroy(&th->interrupt_lock);
- native_cond_destroy(&th->interrupt_cond);
native_thread_destroy(th);
}
@@ -739,7 +737,6 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
th->interrupt_mask = 0;
native_mutex_initialize(&th->interrupt_lock);
- native_cond_initialize(&th->interrupt_cond, RB_CONDATTR_CLOCK_MONOTONIC);
th->report_on_exception = th->vm->thread_report_on_exception;
/* kick thread */
@@ -4920,8 +4917,6 @@ Init_Thread(void)
gvl_acquire(th->vm, th);
native_mutex_initialize(&th->vm->thread_destruct_lock);
native_mutex_initialize(&th->interrupt_lock);
- native_cond_initialize(&th->interrupt_cond,
- RB_CONDATTR_CLOCK_MONOTONIC);
th->pending_interrupt_queue = rb_ary_tmp_new(0);
th->pending_interrupt_queue_checked = 0;
@@ -5077,26 +5072,3 @@ rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data)
return rb_ensure(b_proc, data, rb_ary_pop, cur_th->pending_interrupt_mask_stack);
}
-
-void
-ruby_kill(rb_pid_t pid, int sig)
-{
- int err;
- rb_thread_t *th = GET_THREAD();
-
- /*
- * When target pid is self, many caller assume signal will be
- * delivered immediately and synchronously.
- */
- {
- 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();
- }
- if (err < 0) {
- rb_sys_fail(0);
- }
-}
diff --git a/vm_core.h b/vm_core.h
index 52d1bbc..f4301b7 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -791,7 +791,6 @@ typedef struct rb_thread_struct {
rb_atomic_t interrupt_flag;
unsigned long interrupt_mask;
rb_nativethread_lock_t interrupt_lock;
- rb_nativethread_cond_t interrupt_cond;
struct rb_unblock_callback unblock;
VALUE locking_mutex;
struct rb_mutex_struct *keeping_mutexes;