tmux_server:with_server/2
Open a borrowed endpoint, run a callback in the calling process, then close it. Performs the same I/O as open/1 and close/1; the borrowed daemon survives. Startup failure passes through without invoking the callback.
Source and package
- Qualified name
-
tmux_server: with _server/2 - Declared in
tmux_server- Package
- libtmux_erlang
- Source
- apps/libtmux_erlang/src/tmux_server.erl
- with_server(Options, Function) -spec with_server(open
_options (), fun((t()) -> Value)) -> {ok, Value} | {error, scope_failure () | map()}. -
Description#
With successful cleanup, returns {ok, Value} for any callback return value, including a returned error tuple. Callback error, throw and exit exceptions are re-raised with their original reason and stack. If cleanup fails, returns {error, Failure} with
scope_failure/0, preserving both outcomes and the endpoint for explicit recovery. It attempts cleanup once; a timeout does not prove retirement. Existing supervised cleanup ownership remains in force.The callback must retire separately created resources such as
tmux_controlattachments. This scope closes its endpoint, not every resource the callback may allocate. Usewith_owned/2when the scope should own the daemon too.
Guides#
Pages that discuss with_server/2.
- Guides
- Topics