Skip to main content
Use Sandbox.shell() for interactive TTY sessions. It returns a TerminalSession with raw byte streaming and no output buffering, designed for interactive use. For batch command execution, use exec() instead.

Shell session

Create a sandbox and open an interactive shell session. Sandbox.run() with no arguments uses the default long-running command. The examples that follow assume this context is still active.
shell() always allocates a TTY and enables stdin. The returned TerminalSession streams raw bytes with no UTF-8 decode or encode round-trip, making it safe for terminal escape sequences and binary output.

Send commands and read output

With the terminal session open, write commands to stdin and stream the merged byte output back from the remote shell.
TerminalSession doesn’t buffer output. Stdout and stderr are merged into a single raw byte stream on terminal.output. There are no separate stdout or stderr attributes on the result. Consume terminal.output continuously. If you stop reading, backpressure from the bounded queue stalls the remote session.

Terminal resize

Send resize messages when the terminal dimensions change.
resize() is fire-and-forget on TerminalSession.

Exit a shell session

End a shell session by closing stdin or sending an exit command:
The shell session completes when the remote process exits. Call terminal.wait() or terminal.result() to block for the exit code.

Commands and use cases

See also

Last modified on May 29, 2026