Merge pull request #2571 from danielmartin/revert-2517-fix-select-blocking

Revert "Fix `IO#select` blocking."
This commit is contained in:
Markus Reiter 2017-05-01 16:37:56 +02:00 committed by GitHub
commit 8cba0352e0

View File

@ -92,25 +92,17 @@ module Hbc
def each_line_from(sources)
loop do
selected_sources = IO.select(sources, [], [], 10)
break if selected_sources.nil?
readable_sources = selected_sources[0].delete_if(&:eof?)
readable_sources.each do |source|
readable_sources = IO.select(sources)[0]
readable_sources.delete_if(&:eof?).first(1).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