aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorVítor Galvão2017-04-21 13:43:20 +0100
committerGitHub2017-04-21 13:43:20 +0100
commitcc7376246e6919b22456fb5bc114cf9cc3bf6667 (patch)
treeaf269e724767fbed418b75c8c675d951e21be6b5 /Library
parent12fe8957499f80d2ae74102d9222cec8fd81ce43 (diff)
parentcc634b2d50cc0e8c1e8a38196f4bcdad4e0a69b6 (diff)
downloadbrew-cc7376246e6919b22456fb5bc114cf9cc3bf6667.tar.bz2
Merge pull request #2517 from reitermarkus/fix-select-blocking
Fix `IO#select` blocking.
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