summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_thread.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 6f7d1280bd..f7b33c30ec 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -689,20 +689,23 @@ class TestThreadGroup < Test::Unit::TestCase
def test_thread_timer_and_interrupt
bug5757 = '[ruby-dev:44985]'
t0 = Time.now.to_f
- pid = spawn(EnvUtil.rubybin, '-e', 'r,=IO.pipe;r.read')
- sleep 1;
- Process.kill(:SIGINT, pid)
- Process.wait(pid)
- s = $?
- if /mswin|mingw/ =~ RUBY_PLATFORM
- # status of signal is not supported on Windows
- assert_equal(pid, s.pid)
- else
- assert_equal([false, true, false],
- [s.exited?, s.signaled?, s.stopped?],
- "[s.exited?, s.signaled?, s.stopped?]")
+ pid = nil
+ cmd = 'r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read'
+ s, err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true) do |in_p, out_p, err_p, cpid|
+ out_p.gets
+ pid = cpid
+ Process.kill(:SIGINT, pid)
+ Process.wait(pid)
+ [$?, err_p.read]
end
t1 = Time.now.to_f
+ assert_equal(pid, s.pid)
+ unless /mswin|mingw/ =~ RUBY_PLATFORM
+ # status of signal is not supported on Windows
+ assert_equal([false, true, false, Signal.list["INT"]],
+ [s.exited?, s.signaled?, s.stopped?, s.termsig],
+ "[s.exited?, s.signaled?, s.stopped?, s.termsig]")
+ end
assert_in_delta(t1 - t0, 1, 1)
end
end