Skip to main content

List running processes

for process in sandbox.commands.list():
    state = "running" if process.running else "exited"
    print(process.pid, state, process.command)
ProcessInfo includes pid, command, and running. The list endpoint is useful for reconnecting to background work after a client restart.

Send stdin

process = sandbox.commands.run("python3 -i", shell=True, background=True)
sandbox.commands.send_stdin(process.pid, "print('hello')\n")
sandbox.commands.send_stdin(process.pid, "exit()\n")
send_stdin writes text to the process stdin stream. Use it for interactive programs that are not full terminal sessions; use PTY sessions when terminal behavior, resize, or shell line editing matters.

Logs

logs = sandbox.commands.get_logs(process.pid)
print(logs.stdout)
print(logs.stderr)
print(logs.output)
print(logs.exit_code)
stdout and stderr are split streams. output is the interleaved stream when the backend has it. exit_code is None while the process is still running and an integer after it exits.

Kill

sandbox.commands.kill(process.pid)
Killing a process does not destroy the sandbox. It only stops the selected PID.

REST and CLI map

TaskPython SDKCLIAPI
List processessandbox.commands.list()nullspace sandbox process list sb_123GET /v1/sandboxes/{id}/processes
Fetch logssandbox.commands.get_logs(pid)nullspace sandbox process logs sb_123 1234GET /v1/sandboxes/{id}/processes/{pid}/logs
Send stdinsandbox.commands.send_stdin(pid, data)printf ... | nullspace sandbox process stdin sb_123 1234POST /v1/sandboxes/{id}/processes/{pid}/stdin
Killsandbox.commands.kill(pid)nullspace sandbox process kill sb_123 1234POST /v1/sandboxes/{id}/processes/{pid}/kill
Attach streamsandbox.commands.connect(pid)nullspace sandbox process attach sb_123 1234exec WebSocket
Most CLI process commands accept --json for automation. stdin --json returns the PID and bytes_sent; attach --json returns a CommandResult.