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
This commit is contained in:
parent
98ca921088
commit
a929da7135
@ -40,22 +40,23 @@ class TestSignal < Test::Unit::TestCase
|
|||||||
Process.respond_to?(:pgroup) # for mswin32
|
Process.respond_to?(:pgroup) # for mswin32
|
||||||
|
|
||||||
def test_exit_action
|
def test_exit_action
|
||||||
begin
|
if Signal.list[sig = "USR1"]
|
||||||
r, w = IO.pipe
|
term = :TERM
|
||||||
r0, w0 = IO.pipe
|
else
|
||||||
pid = Process.spawn(EnvUtil.rubybin, '-e', <<-'End', 3=>w, 4=>r0)
|
sig = "INT"
|
||||||
w = IO.new(3, "w")
|
term = :KILL
|
||||||
r0 = IO.new(4, "r")
|
end
|
||||||
Signal.trap(:USR1, "EXIT")
|
IO.popen([EnvUtil.rubybin, '-e', <<-"End"], 'r+') do |io|
|
||||||
w.syswrite("a")
|
Signal.trap(:#{sig}, "EXIT")
|
||||||
|
STDOUT.syswrite("a")
|
||||||
Thread.start { sleep(2) }
|
Thread.start { sleep(2) }
|
||||||
r0.sysread(4096)
|
STDIN.sysread(4096)
|
||||||
End
|
End
|
||||||
r.sysread(1)
|
pid = io.pid
|
||||||
|
io.sysread(1)
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
assert_nothing_raised("[ruby-dev:26128]") {
|
assert_nothing_raised("[ruby-dev:26128]") {
|
||||||
Process.kill(:USR1, pid)
|
Process.kill(term, pid)
|
||||||
term = :TERM
|
|
||||||
begin
|
begin
|
||||||
Timeout.timeout(3) {
|
Timeout.timeout(3) {
|
||||||
Process.waitpid pid
|
Process.waitpid pid
|
||||||
@ -69,11 +70,6 @@ class TestSignal < Test::Unit::TestCase
|
|||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
ensure
|
|
||||||
r.close
|
|
||||||
w.close
|
|
||||||
r0.close
|
|
||||||
w0.close
|
|
||||||
end
|
end
|
||||||
end if Process.respond_to?(:kill)
|
end if Process.respond_to?(:kill)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user