Skip to content

Commit

Permalink
sandbox: fallback to tput for winsize
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Sep 1, 2021
1 parent 008296f commit 45cf5da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Library/Homebrew/sandbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ def exec(*args)
command = [SANDBOX_EXEC, "-f", seatbelt.path, *args]
# Start sandbox in a pseudoterminal to prevent access of the parent terminal.
T.unsafe(PTY).spawn(*command) do |r, w, pid|
old_winch = trap(:WINCH) { w.winsize = $stdout.winsize if $stdout.tty? }
w.winsize = $stdout.winsize if $stdout.tty?
winch = proc do |_sig|
w.winsize = if $stdout.tty?
$stdout.winsize
else
[Utils.popen_read("tput", "lines").to_i, Utils.popen_read("tput", "cols").to_i]
end
end
old_winch = trap(:WINCH, &winch)
winch.call(nil)

$stdin.raw! if $stdin.tty?
stdin_thread = Thread.new { IO.copy_stream($stdin, w) }
Expand Down

0 comments on commit 45cf5da

Please sign in to comment.