Don't clear pending interrupts in the parent process. (#10365)
This commit is contained in:
parent
0c62eb25b5
commit
a7ff264477
@ -1682,7 +1682,6 @@ before_fork_ruby(void)
|
|||||||
static void
|
static void
|
||||||
after_fork_ruby(rb_pid_t pid)
|
after_fork_ruby(rb_pid_t pid)
|
||||||
{
|
{
|
||||||
rb_threadptr_pending_interrupt_clear(GET_THREAD());
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// child
|
// child
|
||||||
clear_pid_cache();
|
clear_pid_cache();
|
||||||
|
@ -2828,4 +2828,25 @@ EOS
|
|||||||
[t1, t2, t3].each { _1&.join rescue nil }
|
[t1, t2, t3].each { _1&.join rescue nil }
|
||||||
[long_rpipe, long_wpipe, short_rpipe, short_wpipe].each { _1&.close rescue nil }
|
[long_rpipe, long_wpipe, short_rpipe, short_wpipe].each { _1&.close rescue nil }
|
||||||
end if defined?(fork)
|
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
|
end
|
||||||
|
1
thread.c
1
thread.c
@ -4725,6 +4725,7 @@ void
|
|||||||
rb_thread_atfork(void)
|
rb_thread_atfork(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
rb_threadptr_pending_interrupt_clear(th);
|
||||||
rb_thread_atfork_internal(th, terminate_atfork_i);
|
rb_thread_atfork_internal(th, terminate_atfork_i);
|
||||||
th->join_list = NULL;
|
th->join_list = NULL;
|
||||||
rb_fiber_atfork(th);
|
rb_fiber_atfork(th);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user