From: Brian Candler Date: 2004-11-02T22:25:51+09:00 Subject: Re: Ruby redirection woes > You actually need to run the test script with a shell redirection. Like > in the example output I gave, I redirected output of the script to a > file, output.txt, and then cat'ed it: > > $ ruby command_runner_shell_test.rb > output.txt > $ cat output.txt My apologies for not reading your post more carefully. Yes, I get the same here - and Matz has posted a patch which fixes it in Ruby. (However I'm not sure that fix is necessarily good; the same problem would happen with other filehandles which are open, and there's no proposal that fork() should flush all those too). However you can also just fix your command_runner.rb like this: --- command_runner.rb.orig Tue Nov 2 13:21:01 2004 +++ command_runner.rb Tue Nov 2 13:21:41 2004 @@ -33,6 +33,8 @@ child_to_parent_read, child_to_parent_write = IO.pipe child_to_parent_error_read, child_to_parent_error_write = IO.pipe + $stdout.flush + $stderr.flush @childPid = fork do parent_to_child_write.close child_to_parent_read.close (The $stderr.flush maybe isn't needed, as I seem to remember that stderr is unbuffered normally, but it won't do any harm to have it there) Regards, Brian.