okay, sorry; i wasnt very clear.

i have an autonomous process that writes to stdout (my example is called
child.rb).  i want to fork this process and read the stdout of the child
process.

the problem is the process produces too much stdout that is fills up the
buffer.  how can you read the stdout before the child process ends?

parent calls child
   child write stdout
parent reads the stdout

here is my example to demo what i am trying to do:  if you run parent.rb 
you will see what i am trying to do.

#######################################
# parent.rb
#######################################

require 'open4'
require './child.rb'

command = 'child.rb'

#try it as return
pid, stdin, stdout, stderr = Open4::popen4(command)

while !stdout.eof? do
  puts stdout.gets
end

###################################


########################
# child.rb is
########################

(0..100).each do |i|
  puts "helloworld #{i}"
  sleep 1
  puts "goodbye world #{i}"
  sleep 1
end

#######################

Attachments:
http://www.ruby-forum.com/attachment/7864/parent.rb
http://www.ruby-forum.com/attachment/7865/child.rb


-- 
Posted via http://www.ruby-forum.com/.