diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-19 15:57:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-19 15:57:14 +0000 |
commit | a929da71351821cfd1f12d6b3d16eb97f1b8c565 (patch) | |
tree | 71c8a22b18f91b009c0dacad075e9c442405beb9 /test/ruby/test_signal.rb | |
parent | 98ca9210881963a1566b0401d36165cf0fd208e6 (diff) |
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
Diffstat (limited to 'test/ruby/test_signal.rb')
-rw-r--r-- | test/ruby/test_signal.rb | 30 |
1 files changed, 13 insertions, 17 deletions
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) |