From: Yukihiro Matsumoto Date: 2004-11-02T16:08:05+09:00 Subject: Re: Ruby redirection woes Hi, In message "Re: Ruby redirection woes" on Tue, 2 Nov 2004 11:14:22 +0900, Steven Kah Hien Wong writes: |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 | Hello, world! 2 times! | Hello, world! 2 times! | Hello, world! 2 times! | |Hopefully that will reproduce the same results I am seeing? Otherwise if |this problem just happens on mine... well that is just going to make it |even more difficult for me to track. :( Both parent and child processes flushes remaining output buffer. We have to flush stdout and stderr before fork(2). Here's the patch. matz. --- process.c 2 Oct 2004 03:50:48 -0000 1.92.2.11 +++ process.c 2 Nov 2004 07:07:49 -0000 @@ -1259,2 +1259,8 @@ rb_f_fork(obj) rb_secure(2); + +#ifndef __VMS + fflush(stdout); + fflush(stderr); +#endif + switch (pid = fork()) {