From: "akr (Akira Tanaka)" Date: 2013-11-06T07:32:39+09:00 Subject: [ruby-core:58188] [ruby-trunk - Bug #9082] popen3 hangs when stderr gets lots of output Issue #9082 has been updated by akr (Akira Tanaka). rosenfeld (Rodrigo Rosenfeld Rosas) wrote: > At least with the block form. I think this should be documented if this is the case. The document already has following description: % ri Open3.popen3 ... You should be careful to avoid deadlocks. Since pipes are fixed length buffer, Open3.popen3("prog") {|i, o, e, t| o.read } deadlocks if the program generates many output on stderr. You should be read stdout and stderr simultaneously (using thread or IO.select). However if you don't need stderr output, Open3.popen2 can be used. If merged stdout and stderr output is not a problem, you can use Open3.popen2e. If you really needs stdout and stderr output as separate strings, you can consider Open3.capture3. ---------------------------------------- Bug #9082: popen3 hangs when stderr gets lots of output https://bugs.ruby-lang.org/issues/9082#change-42773 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Rejected Priority: Normal Assignee: Category: lib Target version: ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] Backport: Create this program test.rb: STDERR.puts "some error line\n" * 10_000 Then, try this: ruby -r open3 -e "Open3.popen3('ruby test.rb'){|i,o,e,t|i.close;o.read}" For this particular case, if I do "e.read" before "o.read" it works. But for my real case involving the "tidy" command with lots of warnings in the stderr it will freeze even if I call "e.read". Since I don't really need this output, I'm using popen2 and redirecting stderr to /dev/null, so this is not urgent, but I thought you'd like to know about this. Also, if you replace 10_000 with 1_000 above it also works here. -- http://bugs.ruby-lang.org/