Rearrange build process cleanup to avoid spawning a reader thread

This is a follow-up to bbf9f7460fc8e6e4c63f5bbe8630b11ca53f3710.

If we read from the pipe before calling Process.wait, we can avoid
spawning a thread to do the read while continuing to avoid the deadlock
that the thread was introduced to solve.
This commit is contained in:
Jack Nagel 2014-09-28 01:37:02 -05:00
parent aaaab946ec
commit 209e7137e3

View File

@ -505,10 +505,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 } data = read.read
Process.wait(pid)
data = thr.value
read.close read.close
Process.wait(pid)
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
raise "Suspicious installation failure" unless $?.success? raise "Suspicious installation failure" unless $?.success?