title: popen3 hangs when executing script with popen3
body: <p>I have next code</p>
  
  <pre><code> def execute_bash(cmd)
    puts "Executing: [#{cmd}]"
    exit_code = Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
      stdin.close
      stdout.each { |line| puts line }
      stdout.close
      stderr.each { |line| puts line }
      stderr.close
      wait_thr.value.exitstatus
    end
    return exit_code
  end
  </code></pre>
  
  <p>Command that I run with this function is vagrant up, that produces a lot of output. I have a lot of recipes so I need to monitor it's output in realtime, line by line.</p>
  
  <p>And I have another script that ensures that previous script did well and did not crash. So I have another script that runs bash commands in the same way as previous. So I'm like running(in second script):</p>
  
  <pre><code>execute_bash "./vagrant_up.rb"
  </code></pre>
  
  <p>Such consequence leads me to dead lock or something: in some point output  stops. I could wait a lot of time but it will not continues.</p>
  
  <p>When I run just vagrant in console - everything is fine.</p>
  
  <p>Is that a problem to run ruby script with popen3 in another popen3?
  Is there proper way of handling dead locks in popen3(if it's dead lock, I'm not sure)?</p>