# 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/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/server_attach.go#L81
- **Page:** https://libtmux.org/reference/go/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.
