From a929da71351821cfd1f12d6b3d16eb97f1b8c565 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 19 Jun 2013 15:57:14 +0000 Subject: test_signal.rb: use standard fds * test/ruby/test_signal.rb (test_exit_action): use IO.popen and standard file descriptors instead of fd 3 and 4, which is not available on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_signal.rb | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index ee63f8d8e0..ba0ee6d9e4 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -40,22 +40,23 @@ class TestSignal < Test::Unit::TestCase Process.respond_to?(:pgroup) # for mswin32 def test_exit_action - begin - r, w = IO.pipe - r0, w0 = IO.pipe - pid = Process.spawn(EnvUtil.rubybin, '-e', <<-'End', 3=>w, 4=>r0) - w = IO.new(3, "w") - r0 = IO.new(4, "r") - Signal.trap(:USR1, "EXIT") - w.syswrite("a") + if Signal.list[sig = "USR1"] + term = :TERM + else + sig = "INT" + term = :KILL + end + IO.popen([EnvUtil.rubybin, '-e', <<-"End"], 'r+') do |io| + Signal.trap(:#{sig}, "EXIT") + STDOUT.syswrite("a") Thread.start { sleep(2) } - r0.sysread(4096) + STDIN.sysread(4096) End - r.sysread(1) + pid = io.pid + io.sysread(1) sleep 0.1 assert_nothing_raised("[ruby-dev:26128]") { - Process.kill(:USR1, pid) - term = :TERM + Process.kill(term, pid) begin Timeout.timeout(3) { Process.waitpid pid @@ -69,11 +70,6 @@ class TestSignal < Test::Unit::TestCase raise end } - ensure - r.close - w.close - r0.close - w0.close end end if Process.respond_to?(:kill) -- cgit v1.2.3