External process output should be read asynchronously to avoid deadlocks
@@ -60,19 +60,24 @@ module Buck
args ||= []
buck.push(command)
buck.push(*args)
+ puts buck.join(' ')
output = ''
Open3.popen3(*buck) do |stdin, stdout, stderr, wait|
- stdin.close
-
+ Thread.new do
while (error = stderr.gets)
STDERR.print(error)
end
+ end
+ Thread.new do
while (line = stdout.gets)
output << line
STDOUT.print line
end
+ end
+
+ stdin.close
raise "#{buck.join(' ')} failed with exit code: #{wait.value.exitstatus}" unless wait.value.success?
end
