A GenServer holding a long-lived interactive command session over WebSocket.
Obtained via Miosa.Exec.spawn/3. Provides stdin/stdout interaction and
terminal resize for PTY-based commands.
The underlying WebSocket is managed via :gun. The GenServer owns the
connection and shuts it down on termination.
Example
{:ok, cmd} = Miosa.Exec.spawn(client, computer_id, "bash")
:ok = Miosa.Exec.Command.send_stdin(cmd, "ls -la\n")
:ok = Miosa.Exec.Command.resize(cmd, 120, 40)
# Block until the command exits (or timeout)
{:ok, exit_code} = Miosa.Exec.Command.await(cmd, 30_000)
Summary
Functions
Blocks until the command exits and returns {:ok, exit_code}.
Returns a specification to start this module under a supervisor.
Signals stdin EOF to the command (closes the write half of the WebSocket).
Sends a terminal resize event (SIGWINCH) to the running command.
Sends data to the command's stdin.
Types
@type t() :: pid()
Functions
@spec await(t(), pos_integer()) :: {:ok, integer()} | {:error, :timeout | term()}
Blocks until the command exits and returns {:ok, exit_code}.
Returns {:error, :timeout} if the command does not exit within timeout_ms.
The GenServer process is stopped after await/2 returns.
Returns a specification to start this module under a supervisor.
See Supervisor.
Signals stdin EOF to the command (closes the write half of the WebSocket).
@spec resize(t(), pos_integer(), pos_integer()) :: :ok | {:error, term()}
Sends a terminal resize event (SIGWINCH) to the running command.
Only meaningful for PTY-based commands (those started with pty: true).
Sends data to the command's stdin.
data should be a binary string (may include newlines).
Returns :ok immediately; delivery is async over the WebSocket.