I'm trying to open a Ruby script that prompts for stuff with popen3
, for testing purposes.
I need to be able to type into the STDIN of the proccess and inspect the outputs. So far I have this:
require 'open3'
def run(executable, opts = {})
Signal.trap('CLD') do
puts 'STDIN:', @stdout.readlines
# @stderr.rewind
puts 'STDERR:', @stderr.readlines
# got EOF, trying to rewind gives me 'Errno::ESPIPE: Illegal seek'
[@stdin, @stdout, @stderr].each &:close
end
@stdin, @stdout, @stderr, @thread = Open3.popen3(executable)
@status = @thread.value
end
Have been trying for days, my brain is melting.