diff options
-rw-r--r-- | bootstraptest/test_ractor.rb | 42 | ||||
-rw-r--r-- | ractor.c | 3 |
2 files changed, 45 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 94c0635c72..19a6e16302 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -2213,7 +2213,49 @@ assert_equal 'ok', %q{ # fork after creating Ractor assert_equal 'ok', %q{ +begin Ractor.new { Ractor.receive } _, status = Process.waitpid2 fork { } status.success? ? "ok" : status +rescue NotImplementedError + :ok +end +} + +# Ractors should be terminated after fork +assert_equal 'ok', %q{ +begin + r = Ractor.new { Ractor.receive } + _, status = Process.waitpid2 fork { + begin + r.take + raise "ng" + rescue Ractor::ClosedError + end + } + r.send(123) + raise unless r.take == 123 + status.success? ? "ok" : status +rescue NotImplementedError + :ok +end +} + +# Ractors should be terminated after fork +assert_equal 'ok', %q{ +begin + r = Ractor.new { Ractor.receive } + _, status = Process.waitpid2 fork { + begin + r.send(123) + raise "ng" + rescue Ractor::ClosedError + end + } + r.send(123) + raise unless r.take == 123 + status.success? ? "ok" : status +rescue NotImplementedError + :ok +end } @@ -2096,6 +2096,9 @@ rb_ractor_terminate_atfork(rb_vm_t *vm, rb_ractor_t *r) rb_gc_ractor_cache_free(r->newobj_cache); r->newobj_cache = NULL; r->status_ = ractor_terminated; + r->sync.outgoing_port_closed = true; + r->sync.incoming_port_closed = true; + r->sync.will_basket.type.e = basket_type_none; } #endif |