aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/system_command.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb
index c14079bc8..65e54b447 100644
--- a/Library/Homebrew/cask/lib/hbc/system_command.rb
+++ b/Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -91,18 +91,32 @@ module Hbc
end
def each_line_from(sources)
+ tries = 3
+
loop do
- readable_sources = IO.select(sources)[0]
- readable_sources.delete_if(&:eof?).first(1).each do |source|
+ selected_sources = IO.select(sources, [], [], 1)
+
+ if selected_sources.nil?
+ next unless (tries -= 1).zero?
+ odebug "IO#select failed, skipping line."
+ break
+ end
+
+ readable_sources = selected_sources[0].delete_if(&:eof?)
+
+ readable_sources.each do |source|
type = (source == sources[0] ? :stdout : :stderr)
+
begin
yield(type, source.readline_nonblock || "")
rescue IO::WaitReadable, EOFError
next
end
end
+
break if readable_sources.empty?
end
+
sources.each(&:close_read)
end