# LibTmux.Control.start_link/1

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/control.ex#L79
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-control-start_link-1/

```
start_link(options)
@spec start_link([start_option()]) ::
        {:ok, pid(), t()} | {:error, LibTmux.Error.t()}
```

Starts a linked connection and returns `{:ok, root, control}`.

Require `server: %LibTmux.Server{}`, `session: {:existing, "$id"}` and
`lane: :host_qualified`. No session is created. The attachment is visible in
tmux's client counts and can update session state. `no-output,ignore-size`
suppresses pane output and excludes this client from window sizing.

`timeout` defaults to 5000ms and accepts 1..600000ms. One budget covers input
preparation, Root startup, bootstrap, ready waiting and handoff. A fresh
factory returns a ready handle. Runtime failures return a structured error;
invalid trusted options raise `ArgumentError`. Ordinary OTP links remain:
an asynchronous fatal Root exit can terminate a non-trapping caller.

Failed startup fences its lifetime and requests exact-Root cleanup. Error
details distinguish observed Root exit from a kill request; unknown native
cleanup is never success. OTP can await Root exit after its initialization
timer expires, so a strict wall-clock caller-return bound remains unqualified.

Optional `capacity`, `metadata_capacity` and `waiter_capacity` default to 32
and accept 1..256. `retention_ms` defaults to 60000 and accepts 1..600000.

Ready connections buffer at most 64 KiB or 128 stdout chunks behind the
reader. Overflow closes the whole epoch with `resource_limit`; it never
replays commands. These receive limits do not cap borrowed-server memory.

See the [worked example](advanced-execution.html).

## Parameters

- `options` (`[start_option()]`)

## tmux command

The tmux commands behind `start_link/1`.

- [`attach-session`](/en/tmux/latest/manual/attach-session/)
- [`display-message`](/en/tmux/latest/manual/display-message/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_attach_session_entry`](/en/tmux/latest/reference/c-variable-cmd_attach_session_entry/) (attribute)
- [`cmd_attach_session_exec`](/en/tmux/latest/reference/c-function-cmd-attach-session-c-cmd_attach_session_exec/) (function)
- [`cmd_display_message_entry`](/en/tmux/latest/reference/c-variable-cmd_display_message_entry/) (attribute)
- [`cmd_display_message_exec`](/en/tmux/latest/reference/c-function-cmd-display-message-c-cmd_display_message_exec/) (function)

## Guides

Pages that discuss `start_link/1`.

- [Execution ownership](/en/elixir/pr-173/topics/ownership/)
