1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2013-12-14 22:34:43 +00:00
parent 23201ab1c4
commit b46441824f

View file

@ -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