# tmux_control:attach/3

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_control.erl#L55
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_control-attach-3/

```
attach(Server, Session, Options)
-spec attach(tmux_server:t(),
             tmux_model:session(),
             attach_options()) ->
                {ok, t()} | {error, map()}.
```

Attach to an existing captured session from this exact endpoint origin. Performs I/O and waits for a same-connection identity probe. Uses [attach-session](/en/tmux/latest/manual/attach-session/) with -E rather than creating a session or writing options. Configured hooks may change state; failure does not reverse their effects. The control client affects attached_count. Unexpected hook-generated reply blocks fail attachment and retire the client.

An attachment timeout requests cleanup. If cleanup cannot be proved within
its finite deadline, the error includes a control handle for `close/1` recovery.
The supervised owner remains until native retirement. Close explicitly to
observe cleanup, including when the parent endpoint is already closed.

## Parameters

- `Server` (`tmux_server:t()`)
- `Session` (`tmux_model:session()`)
- `Options` (`attach_options()`)
