Commit e1822c8d authored by Samuel E. Giddins's avatar Samuel E. Giddins

[Executable] Use readpartial instead of gets

parent 91f1aee8
...@@ -200,4 +200,4 @@ DEPENDENCIES ...@@ -200,4 +200,4 @@ DEPENDENCIES
xcodeproj! xcodeproj!
BUNDLED WITH BUNDLED WITH
1.10.0 1.10.2
...@@ -80,8 +80,9 @@ module Pod ...@@ -80,8 +80,9 @@ module Pod
def self.popen3(bin, command, stdout, stderr) def self.popen3(bin, command, stdout, stderr)
require 'open3' require 'open3'
Open3.popen3(bin, *command) do |i, o, e, t| Open3.popen3(bin, *command) do |i, o, e, t|
Thread.new { while s = o.gets; stdout << s; end } read(o, stdout)
Thread.new { while s = e.gets; stderr << s; end } read(e, stderr)
i.close i.close
status = t.value status = t.value
...@@ -93,6 +94,27 @@ module Pod ...@@ -93,6 +94,27 @@ module Pod
end end
end end
def self.read(input, output)
Thread.new do
buf = ''
begin
while s = input.readpartial(4096)
buf << s
lines = buf.split("\n")
if buf[-1] == "\n"
buf = ''
else
buf = lines[-1]
lines.pop
end
lines.each { |l| output << (l << "\n") }
end
rescue EOFError
nil
end
end
end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# Helper class that allows to write to an {IO} instance taking into account # Helper class that allows to write to an {IO} instance taking into account
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment