# session.Session.detach_clients

- **Module:** session.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session.rs#L764
- **Page:** https://libtmux.org/reference/rs/session-session-detach_clients/

```
session.Session.detach_clients(self) -> Result<(), Error>
```

Detach every client attached to this session.

Succeeds when no client was attached. tmux reports that as a failure,
but the state this asks for -- nobody attached to this session -- is
already true, and a caller that has to tell "detached them" from
"there was nobody" can compare [`crate::Server::clients_or_empty`] before and
after.

# Errors

Returns an error when tmux cannot be reached or refuses the detach for
any other reason.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("busy").await?;

// Nothing is attached in a headless fixture, so this is a no-op.
session.detach_clients().await?;

guard.shutdown().await?;
```
