Merge pull request #16162 from Bo98/system_command-stderr-fix

system_command: fix potential issue of stderr not being read
This commit is contained in:
Mike McQuaid 2023-10-30 14:36:36 +00:00 committed by GitHub
commit 53107a51db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,7 +291,7 @@ class SystemCommand
pending_interrupt = T.let(false, T::Boolean)
until pending_interrupt
until pending_interrupt || sources.empty?
readable_sources = T.let([], T::Array[IO])
begin
Thread.handle_interrupt(ProcessTerminatedInterrupt => :on_blocking) do
@ -302,7 +302,7 @@ class SystemCommand
pending_interrupt = true
end
break if readable_sources.none? do |source|
readable_sources.each do |source|
loop do
line = source.readline_nonblock || ""
yield(sources.fetch(source), line)
@ -310,9 +310,8 @@ class SystemCommand
rescue EOFError
source.close_read
sources.delete(source)
sources.any?
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