On May 10, 2008, at 12:08 AM, Paul Winward wrote:
> Thanks for the suggestion but I'm still having the problem.

if the child program makes a call to setvbuf (as ruby does) there is  
little you can do to alter this behaviour.  otherwise the 'normal'  
approach will work:

cfp:~ > cat a.rb
r, w = IO.pipe

child = fork{ STDOUT.reopen w; w.close; system 'echo 4 && sleep 1 &&  
echo 2' }

w.close

while(( char = r.read(1) ))
   printf "%f : %s\n", Time.now.to_f, char.inspect
end


cfp:~ > ruby a.rb
1210456103.163009 : "4"
1210456103.163153 : "\n"
1210456104.166967 : "2"
1210456104.167023 : "\n"


i might be wrong,  but i really don't think there is anything you can  
do with a child program that alters the buffering mode itself.

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama