# tmux.ControlClient

- **Module:** tmux
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/control_client.go#L27
- **Page:** https://libtmux.org/reference/go/tmux-controlclient/

ControlClient is one attached tmux control-mode process. Create one with [Server.OpenControl]. Concurrent Cmd, Wait, and close calls are supported; exactly one caller may execute NextNotification at a time.

## Members

- `ClientName` (method) — ClientName returns the tmux-assigned identity captured during registration.
- `Server` (method) — Server returns the server handle used to start the control client.
- `Session` (method) — Session returns the materialized session selected during startup.
- `Wait` (method) — Wait blocks until the control process exits or ctx ends. It does not close the notification queue; callers may drain final notifications before Close.
- `CloseContext` (method) — CloseContext starts idempotent control-client shutdown and waits within ctx. The context bounds only the wait: an already-ended context still starts shutdown, and a later call may resume waiting for the same close.
- `Close` (method) — Close stops the control process and releases its notification queue. It is safe to call concurrently and more than once.
- `Reconnect` (method) — Reconnect registers a replacement on the last attached session observed at a reply boundary, then closes the receiver. Failed replacement setup does not initiate receiver shutdown. If shutdown fails, Reconnect returns the live replacement with that error; the caller owns every non-nil result. A receiver whose stream ended cleanly can recover from its last observation. Commands are never replayed.
- `Cmd` (method) — Cmd executes one safely encoded tmux command through the control client. It requires exactly one reply frame and returns [ErrControlReplyCount] otherwise. Use [ControlClient.Call] for aliases that may produce zero or multiple frames.
- `Call` (method) — Call executes one safely encoded tmux command and returns all its reply frames. Cancellation after writing returns [ErrOutcomeUnknown] with the context error while the client drains through the boundary before reuse. A transport failure returns any frames proven before the failure together with [ErrOutcomeUnknown].
- `NextNotification` (method) — NextNotification returns the next ordered control-mode notification. Exactly one caller may execute it at a time. Natural process exit preserves queued notifications until they drain through io.EOF; Close releases the queue and makes subsequent reads report os.ErrClosed. A terminal reader error follows notifications queued before that failure. A full bounded queue likewise drains before reporting [ControlNotificationOverflowError].
- `Notifications` (method) — Notifications returns an iterator over what tmux says without being asked: pane output, and the events behind [ControlNotification].
