Control.with_connection/2
Runs a callback with one connection and owns its native and supervisor cleanup.
Source and package
- Qualified name
-
LibTmux .Control .with _connection/2 - Module
- LibTmux
- Declared in
- Control
- Package
- libtmux
- Source
- lib/libtmux/control.ex
- with_connection(options, callback) @spec with_connection([scope
_option ()], (t() -> value)) :: {:ok, value} | {:error, LibTmux () | Lib.Error .t Tmux (value)} when value: var.Control .Scope Failure .t -
Description#
Takes the explicit server, existing session and host qualification options from
start_link/1. The callback runs in the calling process. Its duration is separate from startup andcleanup_timeout(default 950ms). A dedicated connection owner also requests cleanup when that caller dies.Returns
{:ok, value}after proven connection retirement and Root exit. Cleaned-up exceptions, throws and exits are re-raised with their original stacktrace. If cleanup fails, returns{:error, ScopeFailure}containing the callback's original value or exception and separate cleanup evidence. Startup failures return{:error, Error}; invalid options raise.The control handle is scoped to the callback. Explicit reconnect is allowed inside it; cleanup permanently fences new epochs and retires the current one. Escaped handles cannot reconnect after the scope. Startup retains
start_link/1's OTP initialization limitation; a timeout can report unknown cleanup while its owner is still unwinding startup. It does not promise a hard native process-exit deadline.alias LibTmux.Control
Control.with_connection(options, fn control -> Control.execute(control, LibTmux.Control.Request.field("pid")) end)
Discussed in Getting started