From: Paul Brannan Date: 2002-01-29T01:12:02+09:00 Subject: popen3 and buffering I have a program test.rb: loop do puts "This is a test." sleep 0.01 end And another program pipe.rb: require 'open3' Open3.popen3('ruby test.rb') do |pin, pout, perr| write_map = { pout => $stdout, perr => $stderr, $stdin => pin } loop do retval = select([pout, perr, $stdin], nil, [pin, $stdout, $stderr], nil) puts "select returned" for i in retval[0] str = i.read(512) write_map[i].write(str) end for i in retval[2] exit(1) end end end I run it with: ruby pipe.rb The result is that I wait about half a second, get a screenful of data, wait another half a second, get a screenful of data etc. I would much prefer that the data be line-buffered. The idea is that I would like to talk to an external process and log that process's data to a file, but I would like to be able to tail -f that file. Any ideas? Paul