From: Pito Salas Date: 2009-08-25T05:05:51+09:00 Subject: Asynchronous process to process pipe IO This is slightly subtle question about how a process that reads from a pipe that is being written to by another process may run asynchronously. Here's a code snippet: def start_processing open("|-", "r") do |worker| if worker # here we are in the parent i = 0 worker.each_line do |line| puts "line #{i} i = i+1 end else # here we are in child thread exec("./iacommand.rb") end end end iacommand.rb is invoked as a process within ruby. It does a lot of processing, outputs a line, does a more processing, outputs another line, and so on. I would like to have the "puts" calls occur right when the a line is generated by the script running in the process. The way it is written above, what happens is that the app waits until iacommand.rb exits and then calls the series of puts in immediate succession. So in other words, how do I asynchronously read from a pipe that is being fed by a process? -- Posted via http://www.ruby-forum.com/.