Using ruby 1.8.6 under Linux. For some reason IO.select() seems to be
ignoring the ‘timeout’ parameter. Regardless of what value I put in
there (float or integer) it doesn’t seem to have any effect – if
there isn’t any data available on stdout or stderr, select() just
waits until there is data:
@stdin, @stdout, @stderr = Open3.popen3("./myprog")
return_data = “”
loop do
while result = select([@stdout, @stderr], nil, nil, 0.25)
for data in result[0]
if data == @stdout
return_data = return_data + @stdout.gets
logit("debug: return_data = " + return_data)
elsif data == @stderr
return_data = return_data + @stderr.gets
end
end # for
end # while
logit(“debug: timed out – waiting for data…”)
if return_data != “”
send_to_user(return_data)
return_data = “”
end
end # loop
Am I missing something?
-Steve