Fix style
This commit is contained in:
parent
c88f4c0645
commit
c7b36df879
@ -101,20 +101,20 @@ class Sandbox
|
|||||||
command = [SANDBOX_EXEC, "-f", seatbelt.path, *args]
|
command = [SANDBOX_EXEC, "-f", seatbelt.path, *args]
|
||||||
# Start sandbox in a pseudoterminal to prevent access of the parent terminal.
|
# Start sandbox in a pseudoterminal to prevent access of the parent terminal.
|
||||||
T.unsafe(PTY).spawn(*command) do |r, w, pid|
|
T.unsafe(PTY).spawn(*command) do |r, w, pid|
|
||||||
write_to_pty = proc {
|
# Set the PTY's window size to match the parent terminal.
|
||||||
# Set the PTY's window size to match the parent terminal.
|
# Some formula tests are sensitive to the terminal size and fail if this is not set.
|
||||||
# Some formula tests are sensitive to the terminal size and fail if this is not set.
|
winch = proc do |_sig|
|
||||||
winch = proc do |_sig|
|
w.winsize = if $stdout.tty?
|
||||||
w.winsize = if $stdout.tty?
|
# We can only use IO#winsize if the IO object is a TTY.
|
||||||
# We can only use IO#winsize if the IO object is a TTY.
|
$stdout.winsize
|
||||||
$stdout.winsize
|
else
|
||||||
else
|
# Otherwise, default to tput, if available.
|
||||||
# Otherwise, default to tput, if available.
|
# This relies on ncurses rather than the system's ioctl.
|
||||||
# This relies on ncurses rather than the system's ioctl.
|
[Utils.popen_read("tput", "lines").to_i, Utils.popen_read("tput", "cols").to_i]
|
||||||
[Utils.popen_read("tput", "lines").to_i, Utils.popen_read("tput", "cols").to_i]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
write_to_pty = proc do
|
||||||
begin
|
begin
|
||||||
# Update the window size whenever the parent terminal's window size changes.
|
# Update the window size whenever the parent terminal's window size changes.
|
||||||
old_winch = trap(:WINCH, &winch)
|
old_winch = trap(:WINCH, &winch)
|
||||||
@ -129,9 +129,10 @@ class Sandbox
|
|||||||
stdin_thread&.kill
|
stdin_thread&.kill
|
||||||
trap(:WINCH, old_winch)
|
trap(:WINCH, old_winch)
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
if $stdout.tty?
|
|
||||||
$stdin.raw &write_to_pty
|
if $stdin.tty?
|
||||||
|
$stdin.raw(&write_to_pty)
|
||||||
else
|
else
|
||||||
write_to_pty.call
|
write_to_pty.call
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user