sandbox: check if stdin/out is associated with a tty
This commit is contained in:
parent
aa04277dc2
commit
d4c691e91e
@ -97,15 +97,17 @@ class Sandbox
|
||||
seatbelt.close
|
||||
@start = Time.now
|
||||
|
||||
$stdin.raw!
|
||||
$stdin.raw! if $stdin.tty?
|
||||
stdin_thread = T.let(nil, T.nilable(Thread))
|
||||
|
||||
begin
|
||||
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|
|
||||
w.winsize = $stdout.winsize
|
||||
trap(:WINCH) { w.winsize = $stdout.winsize }
|
||||
if $stdout.tty?
|
||||
w.winsize = $stdout.winsize
|
||||
trap(:WINCH) { w.winsize = $stdout.winsize }
|
||||
end
|
||||
stdin_thread = Thread.new { IO.copy_stream($stdin, w) }
|
||||
r.each_char { |c| print(c) }
|
||||
Process.wait(pid)
|
||||
@ -116,7 +118,7 @@ class Sandbox
|
||||
raise
|
||||
ensure
|
||||
stdin_thread&.kill
|
||||
$stdin.cooked!
|
||||
$stdin.cooked! if $stdin.tty?
|
||||
|
||||
seatbelt.unlink
|
||||
sleep 0.1 # wait for a bit to let syslog catch up the latest events.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user