aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/system_command.rb12
1 files changed, 10 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..f1ec34025 100644
--- a/Library/Homebrew/cask/lib/hbc/system_command.rb
+++ b/Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -92,17 +92,25 @@ module Hbc
def each_line_from(sources)
loop do
- readable_sources = IO.select(sources)[0]
- readable_sources.delete_if(&:eof?).first(1).each do |source|
+ selected_sources = IO.select(sources, [], [], 10)
+
+ break if selected_sources.nil?
+
+ 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