From 9bd0661e7b02c1bc97fee39b66cda8ab32a2040d Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 29 Jul 2018 20:28:56 +0000 Subject: test/ruby/test_process.rb (test_wait_and_sigchld): improve reliability This should fix CI failure under MJIT, 100ms wait may not be enough for signal handler to fire: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1169472 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_process.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 6a32702b03..5cc49c1a1d 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1588,20 +1588,22 @@ class TestProcess < Test::Unit::TestCase skip "this fails on FreeBSD and OpenBSD on multithreaded environment" end signal_received = [] - Signal.trap(:CHLD) { signal_received << true } - pid = nil - IO.pipe do |r, w| - pid = fork { r.read(1); exit } - Thread.start { - Thread.current.report_on_exception = false - raise - } - w.puts - end - Process.wait pid - 10.times do - break unless signal_received.empty? - sleep 0.01 + IO.pipe do |sig_r, sig_w| + Signal.trap(:CHLD) do + signal_received << true + sig_w.write('?') + end + pid = nil + IO.pipe do |r, w| + pid = fork { r.read(1); exit } + Thread.start { + Thread.current.report_on_exception = false + raise + } + w.puts + end + Process.wait pid + assert sig_r.wait_readable(5), 'self-pipe not readable' end assert_equal [true], signal_received, " [ruby-core:19744]" rescue NotImplementedError, ArgumentError -- cgit v1.2.3