Merge pull request #15255 from reitermarkus/open3-tty-width

Pass TTY width to `Open3`.
This commit is contained in:
Mike McQuaid 2023-04-18 08:43:53 +01:00 committed by GitHub
commit 434f897717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,10 +197,13 @@ class SystemCommand
} }
options[:chdir] = chdir if chdir options[:chdir] = chdir if chdir
pid = T.let(nil, T.nilable(Integer))
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = ignore_interrupts do raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = ignore_interrupts do
Open3.popen3(env, [executable, executable], *args, **options) Open3.popen3(
.tap { |*, wait_thr| pid = wait_thr.pid } env.merge({ "COLUMNS" => Tty.width.to_s }),
[executable, executable],
*args,
**options,
)
end end
write_input_to(raw_stdin) write_input_to(raw_stdin)
@ -228,7 +231,7 @@ class SystemCommand
thread_done_queue << true thread_done_queue << true
line_thread.join line_thread.join
rescue Interrupt rescue Interrupt
Process.kill("INT", pid) if pid && !sudo? Process.kill("INT", raw_wait_thr.pid) if raw_wait_thr && !sudo?
raise Interrupt raise Interrupt
rescue SystemCallError => e rescue SystemCallError => e
@status = $CHILD_STATUS @status = $CHILD_STATUS