diff options
-rw-r--r-- | process.c | 1 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 21 | ||||
-rw-r--r-- | thread.c | 1 |
3 files changed, 22 insertions, 1 deletions
@@ -1682,7 +1682,6 @@ before_fork_ruby(void) static void after_fork_ruby(rb_pid_t pid) { - rb_threadptr_pending_interrupt_clear(GET_THREAD()); if (pid == 0) { // child clear_pid_cache(); diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 8982ab8b9a..59140ba664 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -2828,4 +2828,25 @@ EOS [t1, t2, t3].each { _1&.join rescue nil } [long_rpipe, long_wpipe, short_rpipe, short_wpipe].each { _1&.close rescue nil } end if defined?(fork) + + def test_handle_interrupt_with_fork + Thread.handle_interrupt(RuntimeError => :never) do + Thread.current.raise(RuntimeError, "Queued error") + + assert_predicate Thread, :pending_interrupt? + + pid = Process.fork do + if Thread.pending_interrupt? + exit 1 + end + end + + _, status = Process.waitpid2(pid) + assert_predicate status, :success? + + assert_predicate Thread, :pending_interrupt? + end + rescue RuntimeError + # Ignore. + end if defined?(fork) end @@ -4725,6 +4725,7 @@ void rb_thread_atfork(void) { rb_thread_t *th = GET_THREAD(); + rb_threadptr_pending_interrupt_clear(th); rb_thread_atfork_internal(th, terminate_atfork_i); th->join_list = NULL; rb_fiber_atfork(th); |