From: Ferenc Engard Date: 2004-01-19T02:34:43+09:00 Subject: Re: running external process? > > The problem with popen is, if I want to feed a few MB's of input to it, > > then it hangs (I suspect that its stdout IO buffer is full) before I > > could read out its stdout on the next line. So, the following do not > > work: > > > > io=IO.popen("externalfilter") > > io.write(verybigstring) > > result=io.read > > You need at least two threads or non blocking IO. How about: > > IO.popen( "cat", "w+" ) do |io| > r = Thread.new(io) do |reader| > while ( line = reader.gets ) > line.chomp! > $stdout.puts line > end > end > > (1..100000).each {|i| io.puts i} > r.join > end Thank you, this is what I need. Since I program in ruby, a 8-9 rows of code seems too difficult to write by myself. :-/ Ferenc