# control.ControlMode.attach

- **Module:** control.ControlMode
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/control.rs#L450
- **Page:** https://libtmux.org/reference/rs/control-controlmode-attach/

```
control.ControlMode.attach(server: &Server, session: &SessionId) -> Result<Self, Error>
```

Attach to a session in control mode.

When this returns, tmux has the client attached: anything that changes
the server afterwards is reported. Returning as soon as the process
started would look the same and lose every notification racing the
attach, which is the hardest kind of bug to see.

# Errors

Returns an error when tmux cannot be started, does not give the crate
the pipes it asked for, exits before attaching, or does not finish its
opening block before the server deadline.
