Skip to content

Commit

Permalink
Merge pull request #17835 from Homebrew/system_command-ebadf
Browse files Browse the repository at this point in the history
system_command: fix EBADF on Ctrl+C
  • Loading branch information
Bo98 authored Jul 23, 2024
2 parents a0bd54c + 5ab907f commit 8e8ce4a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Library/Homebrew/system_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,16 @@ def each_output_line(&block)
raise Timeout::Error if raw_wait_thr.join(Utils::Timer.remaining(end_time)).nil?

@status = raw_wait_thr.value

thread_ready_queue.pop
line_thread.raise ProcessTerminatedInterrupt.new
thread_done_queue << true
line_thread.join
rescue Interrupt
Process.kill("INT", raw_wait_thr.pid) if raw_wait_thr && !sudo?
raise Interrupt
ensure
if line_thread
thread_ready_queue.pop
line_thread.raise ProcessTerminatedInterrupt.new
thread_done_queue << true
line_thread.join
end
raw_stdin&.close
raw_stdout&.close
raw_stderr&.close
Expand Down

0 comments on commit 8e8ce4a

Please sign in to comment.