# tmux.Server.AttachSession

- **Module:** tmux.Server
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/server_attach.go#L85
- **Page:** https://libtmux.org/en/go/latest/reference/tmux-server-attachsession/

```
tmux.Server.AttachSession(ctx: context.Context, request: AttachSessionRequest) -> error
```

AttachSession attaches the caller's terminal to a matching session and blocks until detach or context cancellation. Nil standard streams inherit the process streams; each stream must be a concrete terminal descriptor. The call retains caller-supplied files while attached and never owns or closes them. A completed nonzero exit returns [CommandError]; cancellation can end waiting but does not prove that attachment or detachment did not occur.

Alone among this package's operations, it leaves tmux's own locale detection
alone, because what tmux writes here reaches the caller's terminal rather
than this package. See [Session.Attach] for the session-scoped form.
