diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-07-06 13:26:26 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-07-06 13:26:26 +0900 |
| commit | 5577e5d396cc8f062833b67d6280db6cc8501e7a (patch) | |
| tree | 5b762eec93ceb2bdd5978f371ebb84231731637c | |
| parent | 2f8f17e842666abb05ca522d6072c957fab0e12e (diff) | |
merge revision(s) a7ff264477105b5dc0ade6facad4176a1b73df0b: [Backport #20393]
Don't clear pending interrupts in the parent process. (#10365)
| -rw-r--r-- | process.c | 1 | ||||
| -rw-r--r-- | test/ruby/test_process.rb | 21 | ||||
| -rw-r--r-- | thread.c | 1 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 23 insertions, 2 deletions
@@ -1786,7 +1786,6 @@ before_fork_ruby(void) static void after_fork_ruby(void) { - rb_threadptr_pending_interrupt_clear(GET_THREAD()); after_exec(); } #endif diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 939a4268d7..1228f2c0b1 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -2713,4 +2713,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 @@ -4660,6 +4660,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); @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 4 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 179 +#define RUBY_PATCHLEVEL 180 #include "ruby/version.h" #include "ruby/internal/abi.h" |
