IO.select timeout problem

S

sgibson

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

inspire

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] open4-0.9.0 0
[ANN] open4-0.8.0 2
Wrapping applications in Ruby 8
[ANN] open4-0.5.1 0
Help: expect.rb 4
Writing to file delay 5
capture output in real time 9
[ANN] session-2.1.8 3

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top