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
|
||||
after_fork_ruby(rb_pid_t pid)
|
||||
{
|
||||
rb_threadptr_pending_interrupt_clear(GET_THREAD());
|
||||
if (pid == 0) {
|
||||
// child
|
||||
clear_pid_cache();
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user