From: Jeff Putsch Date: 2002-08-23T23:48:09+09:00 Subject: Re: Why does this hang? Much thanks to Nobu for his explanation and his correction of my sample code. I'm no longer stuck and understand not only how to do this, but why! Jeff. On Fri, Aug 23, 2002 at 11:32:46AM +0900, nobu.nokada@softhome.net wrote: > IO#eof? tries to read next data to examin EOF reached. Use > select before eof?. > > def run_command > stdin, out, err = Open3.popen3("cat /etc/ifhp.conf") > > select_on = [out, err] > while !select_on.empty? and r = select(select_on) > p r > > r[0].each {|fh| > if fh.eof? > select_on.delete(fh) > next > elsif fh == out > puts "out: #{fh.gets.to_s}" > elsif fh == err > puts "err: #{fh.gets.to_s}" > end > } > $stdout.flush > end > end -- Jeff Putsch Email: putsch@mxim.com Maxim Integrated Products Office: (503)547-2037 High Frequency CAD Engineering