def test_s_popen_spawn
unless WIN32
# Spawn an interpreter - WRITE
parent = $$
pipe = IO.popen("-", "w")
if pipe
begin
assert_equal(parent, $$)
pipe.puts "12"
Process.wait pipe.pid
assert_equal(12, $?>>8)
ensure
pipe.close
end
else
buff = $stdin.gets
exit buff.to_i
end
# Spawn an interpreter - READWRITE
parent = $$
p = IO.popen("-", "w+")
if p
begin
assert_equal(parent, $$)
p.puts "Hello\n"
assert_equal("Goodbye\n", p.gets)
Process.wait
ensure
p.close
end
else
puts "Goodbye" if $stdin.gets == "Hello\n"
exit
end
end
end