system_command: fix potential issue of stderr not being read
This commit is contained in:
parent
700c7dea3f
commit
dd9359df12
@ -291,7 +291,7 @@ class SystemCommand
|
|||||||
|
|
||||||
pending_interrupt = T.let(false, T::Boolean)
|
pending_interrupt = T.let(false, T::Boolean)
|
||||||
|
|
||||||
until pending_interrupt
|
until pending_interrupt || sources.empty?
|
||||||
readable_sources = T.let([], T::Array[IO])
|
readable_sources = T.let([], T::Array[IO])
|
||||||
begin
|
begin
|
||||||
Thread.handle_interrupt(ProcessTerminatedInterrupt => :on_blocking) do
|
Thread.handle_interrupt(ProcessTerminatedInterrupt => :on_blocking) do
|
||||||
@ -302,7 +302,7 @@ class SystemCommand
|
|||||||
pending_interrupt = true
|
pending_interrupt = true
|
||||||
end
|
end
|
||||||
|
|
||||||
break if readable_sources.none? do |source|
|
readable_sources.each do |source|
|
||||||
loop do
|
loop do
|
||||||
line = source.readline_nonblock || ""
|
line = source.readline_nonblock || ""
|
||||||
yield(sources.fetch(source), line)
|
yield(sources.fetch(source), line)
|
||||||
@ -310,9 +310,8 @@ class SystemCommand
|
|||||||
rescue EOFError
|
rescue EOFError
|
||||||
source.close_read
|
source.close_read
|
||||||
sources.delete(source)
|
sources.delete(source)
|
||||||
sources.any?
|
|
||||||
rescue IO::WaitReadable
|
rescue IO::WaitReadable
|
||||||
true
|
# We've got all the data that was ready, but the other end of the stream isn't finished yet
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user