From: Matthew Purdy Date: 2012-11-02T06:06:52+09:00 Subject: streaming stdout with open4 to prevent parent/child buffer lock i have to fork a process and read a large amount of stdout; however, the child buffer gets filled up and everything hangs. how do you read stdout as stream? the only way i know how to do this is the following two ways; but both do not work; how can you get the stdout when the method starts so you can read stdout as it get written to from the child process? if not, what is an alternative? below is two sample scripts to show the use case. ####################################### open4_test.rb ####################################### command = 'ruby test_run.rb' #try it as return pid, stdin, stdout, stderr = Open4::popen4(command) while !stdout.eof? do puts stdout.gets end #try it with a block status = Open4::popen4(command) do |pid, stdin, stdout, stderr| puts stdout.gets if !stdout.eof? end ################################### ######################## test_run.rb is ######################## (0..100).each do |i| puts "helloworld #{i}" sleep 1 puts "goodbye world #{i}" sleep 1 end ####################### -- Posted via http://www.ruby-forum.com/.