# tmuxtest.ControlMode

- **Module:** tmuxtest
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/tmuxtest/control.go#L29
- **Page:** https://libtmux.org/reference/go/tmuxtest-controlmode/

ControlMode is an attached tmux control client for real-tmux tests. It owns one stdout reader and a temporary-file spool, which preserves unread protocol output until [ControlMode.Close] releases it. Instances come from [NewControlMode]; do not construct them directly or read concurrently.

## Members

- `CloseContext` (method) — CloseContext starts an idempotent shutdown and waits within ctx. Concurrent calls join the same shutdown. If ctx ends after shutdown starts, shutdown continues and a later call may wait for completion; an already-ended ctx does not start shutdown.
- `ClientName` (method) — ClientName returns the tmux-assigned identity captured at registration.
- `Server` (method) — Server returns the validated server handle captured at construction.
- `Session` (method) — Session returns the validated session handle captured at construction.
- `Read` (method) — Read reads control-protocol output within ctx. Exactly one caller may read at a time. After the client exits, callers may drain preserved output through [io.EOF]; after [ControlMode.Close], a non-empty Read returns [os.ErrClosed]. It returns ctx errors while waiting for output.
- `Wait` (method) — Wait blocks until the control client exits or ctx ends. It does not stop or close the client; use [ControlMode.Close] to release it.
- `Close` (method) — Close stops the control client and releases its output spool. It is safe to call concurrently and more than once.
