summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_fork.rb7
-rw-r--r--thread.c1
-rw-r--r--thread_pthread.c5
3 files changed, 12 insertions, 1 deletions
diff --git a/bootstraptest/test_fork.rb b/bootstraptest/test_fork.rb
index a54316dbca..860ef285d0 100644
--- a/bootstraptest/test_fork.rb
+++ b/bootstraptest/test_fork.rb
@@ -85,13 +85,18 @@ assert_equal 'ok', %q{
10.times do
pid = fork{ exit!(0) }
deadline = now + 10
- until Process.waitpid(pid, Process::WNOHANG)
+ while true
+ _, status = Process.waitpid2(pid, Process::WNOHANG)
+ break if status
if now > deadline
Process.kill(:KILL, pid)
raise "failed"
end
sleep 0.001
end
+ unless status.success?
+ raise "child exited with status #{status}"
+ end
rescue NotImplementedError
end
:ok
diff --git a/thread.c b/thread.c
index 7b7d38ec8a..f07f6fba5c 100644
--- a/thread.c
+++ b/thread.c
@@ -4764,6 +4764,7 @@ static void
terminate_atfork_i(rb_thread_t *th, const rb_thread_t *current_th)
{
if (th != current_th) {
+ rb_native_mutex_initialize(&th->interrupt_lock);
rb_mutex_abandon_keeping_mutexes(th);
rb_mutex_abandon_locking_mutex(th);
thread_cleanup_func(th, TRUE);
diff --git a/thread_pthread.c b/thread_pthread.c
index ba229a6dfd..8ba1ad48d3 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1550,6 +1550,11 @@ thread_sched_atfork(struct rb_thread_sched *sched)
vm->ractor.sched.running_cnt = 0;
rb_native_mutex_initialize(&vm->ractor.sched.lock);
+#if VM_CHECK_MODE > 0
+ vm->ractor.sched.lock_owner = NULL;
+ vm->ractor.sched.locked = false;
+#endif
+
// rb_native_cond_destroy(&vm->ractor.sched.cond);
rb_native_cond_initialize(&vm->ractor.sched.cond);
rb_native_cond_initialize(&vm->ractor.sched.barrier_complete_cond);