A handle to a background command started with E2bEx.Commands.start/4 (or
reconnected via E2bEx.Commands.connect/4).
Output is delivered to the subscriber process as messages tagged with the
handle's ref:
{ref, {:stdout, binary}}
{ref, {:stderr, binary}}
{ref, {:exit, %E2bEx.CommandResult{}}} # terminal, any exit code
{ref, {:error, %E2bEx.Error{}}} # terminal, failureConsume the message stream or call wait/1 (which drains the stream and
returns the result) — not both from the same process.
Summary
Functions
Close the command's stdin (EOF).
Stop streaming from the command without killing it. The envd process keeps
running; reconnect with E2bEx.Commands.connect/4. No terminal message is sent.
Kill the command (SIGKILL). {:ok, false} if it was already gone.
The envd process id of the running command.
Send data to the command's stdin (requires start(stdin: true)).
Block until the command finishes and return its result.
Types
@type t() :: %E2bEx.CommandHandle{ context: map(), pid: non_neg_integer(), ref: reference(), server: pid() }
Functions
@spec close_stdin(t()) :: :ok | {:error, E2bEx.Error.t()}
Close the command's stdin (EOF).
@spec disconnect(t()) :: :ok
Stop streaming from the command without killing it. The envd process keeps
running; reconnect with E2bEx.Commands.connect/4. No terminal message is sent.
@spec kill(t()) :: {:ok, boolean()} | {:error, E2bEx.Error.t()}
Kill the command (SIGKILL). {:ok, false} if it was already gone.
@spec pid(t()) :: non_neg_integer()
The envd process id of the running command.
@spec send_stdin(t(), binary()) :: :ok | {:error, E2bEx.Error.t()}
Send data to the command's stdin (requires start(stdin: true)).
@spec wait(t()) :: {:ok, E2bEx.CommandResult.t()} | {:error, E2bEx.Error.t()}
Block until the command finishes and return its result.
Drains the intermediate {ref, {:stdout|:stderr, _}} messages from the caller's
mailbox and returns on the terminal message: {:ok, %E2bEx.CommandResult{}} for
any exit code, or {:error, %E2bEx.Error{}}. Must be called from the subscriber
process. Returns {:error, %E2bEx.Error{}} if the handle server crashes.