summaryrefslogtreecommitdiff
path: root/test/fiber/test_process.rb
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-03-13 11:47:39 +0900
committernagachika <nagachika@ruby-lang.org>2022-03-13 11:47:39 +0900
commit6a8c166498b856ca1dcb53248f0be5fc138f1af3 (patch)
treebf1f3fa0f4c2c75d187f95135967bac5fd053a6a /test/fiber/test_process.rb
parent42b1e87ba7856f92973924985a63a60b5fa750c8 (diff)
merge revision(s) 5c7af72304d0ad33cd3f21b24a4bc44e8acd5b2c,d650b17686d49c2ce8e6a87039861154e93d4621: [Backport #18497]
Assuming EXIT_SUCCESS equals 0 is not portable --- test/ruby/test_fiber.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) `rb_fiber_terminate` must not return [Bug #18497] In a forked process from a fiber, the fiber becomes the only fiber, `fiber_switch` does nothing as there is no other fibers, `rb_fiber_terminate` does not terminate the fiber. In that case, reaches the end of `fiber_entry` finaly, which is declared as "COROUTINE" and should never return. --- cont.c | 3 ++- eval_intern.h | 2 +- test/fiber/test_process.rb | 15 +++++++++++++++ test/ruby/test_fiber.rb | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-)
Diffstat (limited to 'test/fiber/test_process.rb')
-rw-r--r--test/fiber/test_process.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/fiber/test_process.rb b/test/fiber/test_process.rb
index c6583cac9b..a5990be204 100644
--- a/test/fiber/test_process.rb
+++ b/test/fiber/test_process.rb
@@ -33,4 +33,19 @@ class TestFiberProcess < Test::Unit::TestCase
end
end.join
end
+
+ def test_fork
+ omit 'fork not supported' unless Process.respond_to?(:fork)
+ Thread.new do
+ scheduler = Scheduler.new
+ Fiber.set_scheduler scheduler
+
+ Fiber.schedule do
+ pid = Process.fork {}
+ Process.wait(pid)
+
+ assert_predicate $?, :success?
+ end
+ end.join
+ end
end