2013/3/30 Tanaka Akira <akr / fsij.org>:
> 2013/3/30 Jason Gladish <jason / expectedbehavior.com>:
>>
>> I've found an issue where calling fork inside a thread, and passing a block
>> to the fork, causes the forked process to continue after the block.  I've
>> reproduced the issue on the following versions of ruby:
>
> It seems buffered IO data is flushed in several child processes.
> The contorol itself dosen't continue after the block.
>
> exit!(true) solves the problem because it doesn't flush IO.
> Also, if you use f.syswrite instead of f.write, the problem disappears.
>
> The problem is reproduced more reliably by sleeping a second after f.write.

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".
-- 
Tanaka Akira