From: Pito Salas Date: 2009-08-25T05:29:18+09:00 Subject: Re: Asynchronous process to process pipe IO Joel VanderWerf wrote: > Pito Salas wrote: >> worker.each_line do |line| >> iacommand.rb is invoked as a process within ruby. It does a lot of >> So in other words, how do I asynchronously read from a pipe that is >> being fed by a process? > > Hm, the following shows output at 1 sec intervals: > > open("|-", "r") do |worker| > if worker > i = 0 > worker.each_line do |line| > puts "line #{i}:#{line}" > i = i+1 > end > else > exec("ruby -e '3.times {|i| p i; sleep 1}'") > end > end > > Does it work that way for you? Yes it does. Double-hm. My case is using a second ruby file, iacommand.rb, which is doing much the same as what your -e is doing. I wonder if that makes the difference? Or it must be something else. -- Posted via http://www.ruby-forum.com/.