title: Ruby file output from fork
body: <p>I have one simple script:</p>
  
  <pre><code>fork do
    STDOUT.reopen(File.open('/tmp/log', 'w+'))
    STDOUT.sync = true
    exec 'bundle exec ruby script.rb'
  end
  </code></pre>
  
  <p>script.rb:</p>
  
  <pre><code>loop do
      sleep 1
      puts "MESSAGE"
  end
  </code></pre>
  
  <p>When it work, all outputs is buffering(?) and writes to <code>/tmp/log</code> by big pices.<br>
  It works only if I modify script:</p>
  
  <pre><code>$stdout.puts "MESSAGE"
  $stdout.flush
  </code></pre>
  
  <p>How can I do the same <strong>without</strong> modifying <code>script.rb</code> ?<br>
  Thanks.</p>