Read from the error pipe in a separate thread

If the build process tries to write more bytes than will fit in the pipe
buffer, it will block until the parent process does a read. However, the
parent process will only do a read after the child process has exited or
died, leading to a deadlock. Fix this by doing the read in a separate
thread.
This commit is contained in:
Jack Nagel 2014-08-08 17:31:13 -05:00
parent dfe1de7acd
commit a6bf5fa2ba

View File

@ -515,8 +515,9 @@ class FormulaInstaller
ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
write.close write.close
thr = Thread.new { read.read }
Process.wait(pid) Process.wait(pid)
data = read.read data = thr.value
read.close read.close
raise Marshal.load(data) unless data.nil? or data.empty? raise Marshal.load(data) unless data.nil? or data.empty?
raise Interrupt if $?.exitstatus == 130 raise Interrupt if $?.exitstatus == 130