> I wrote a simple script to reproduce the problem.
> This script doesn't use multi-threads.
>
> % ./ruby -ve '
> open("zz", "w") {|f|
>   f.print "foo\n"
>   Process.wait fork {}
>   p $$
> }
> '
> ruby 2.1.0dev (2013-04-01 trunk 40040) [x86_64-linux]
> 4784
> % cat zz
> foo
> foo
>
> The buffered data in f, "foo\n", is flushed in the child process and
> the parent process.
> So zz has two "foo\n".

I believe fork() should flush all IO objects automatically. 1) Why user
should know how ruby beffering? 2) fork() is not common method and
performance disadvantage is not much though.