IO.select timeout problem

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

I’m having this same problem - wish I had a better solution to offer
you! Perhaps it’s just broken this version of linux, or something
more complicated in the code is causing problems…

Linux 2.6.18

It must be something more complicated in the code ,as this works fine:
loop do
while result = select([], nil, nil, 0.25)
puts “GOT RESULT”;
end
puts “looped”
end

Ciao,
Kevin