diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-14 22:34:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-14 22:34:43 +0000 |
commit | b46441824fc1f666b9231f01f2f8ce9f7ac7b3ba (patch) | |
tree | 51a51e791fba25171db936113dae1e2053e7dff7 /test/ruby/test_process.rb | |
parent | 23201ab1c4c71c5f53dd3e69dfe1571cade92609 (diff) | |
download | ruby-b46441824fc1f666b9231f01f2f8ce9f7ac7b3ba.tar.gz |
test_process.rb: handshake
* test/ruby/test_process.rb: handshake by pipe instead of sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_process.rb')
-rw-r--r-- | test/ruby/test_process.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 93b3254038..6586a06fa5 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1186,10 +1186,14 @@ class TestProcess < Test::Unit::TestCase return unless Signal.list.include?("QUIT") with_tmpchdir do - write_file("foo", "sleep 30") - pid = spawn(RUBY, "foo") - Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) } - Process.wait(pid) + write_file("foo", "puts;STDOUT.flush;sleep 30") + pid = nil + IO.pipe do |r, w| + pid = spawn(RUBY, "foo", out: w) + w.close + Thread.new { r.read(1); Process.kill(:SIGQUIT, pid) } + Process.wait(pid) + end t = Time.now s = $? assert_equal([false, true, false], @@ -1336,10 +1340,17 @@ class TestProcess < Test::Unit::TestCase end signal_received = [] Signal.trap(:CHLD) { signal_received << true } - pid = fork { sleep 0.1; exit } - Thread.start { raise } + pid = nil + IO.pipe do |r, w| + pid = fork { r.read(1); exit } + Thread.start { raise } + w.puts + end Process.wait pid - sleep 0.1 + 10.times do + break unless signal_received.empty? + sleep 0.01 + end assert_equal [true], signal_received, " [ruby-core:19744]" rescue NotImplementedError, ArgumentError ensure |