# Libtmux_unix.Terminal.attach_current

- **Module:** Libtmux_unix
- **Package:** libtmux-unix
- **Language:** OCaml
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ocaml/blob/205dfda49742592b479247049d186956e4a4cfe9/unix/libtmux_unix.mli#L82
- **Public owner:** Libtmux_unix
- **Page:** https://libtmux.org/en/ocaml/latest/reference/libtmux_unix-terminal-attach_current/

```
val attach_current :
  ?cancel:Cancellation.t ->
  ?cleanup:Cleanup.t ->
  ?binary:string ->
  ?read_only:bool ->
  ?update_environment:bool ->
  ?stdin:Unix.file_descr ->
  ?stdout:Unix.file_descr ->
  ?stderr:Unix.file_descr ->
  Libtmux.Endpoint.t ->
  session:Libtmux.Session.Id.t -> (unit, Libtmux.Error.t) result
```

Run an interactive terminal client until it exits. Select the exact session ID on the daemon currently listening at `endpoint`; this is explicitly unbound and accepts no captured target. No retry or daemon startup occurs. A successful result proves client exit, not continued attachment. Diagnostics go to `stderr`.

Descriptors default to the application's standard streams and remain caller-owned. `stdin` must be a terminal. Environment updates and read-only mode are disabled by default; inherited `TMUX` and `TMUX_PANE` are removed. Cancellation terminates and reaps this terminal client, leaves the daemon running, then raises [`Cancellation.Cancelled`](/en/ocaml/latest/reference/libtmux_unix-cancellation-cancelled/). TERM gets 200 ms of cooperative grace before KILL and reaping. Scheduling and uninterruptible kernel work can add time. Supply `cleanup` before the call to retain secondary failures after cancellation.

## Parameters

- `cancel?` (`Cancellation.t`)
- `cleanup?` (`Cleanup.t`)
- `binary?` (`string`)
- `read_only?` (`bool`)
- `update_environment?` (`bool`)
- `stdin?` (`Unix.file_descr`)
- `stdout?` (`Unix.file_descr`)
- `stderr?` (`Unix.file_descr`)
- `arg1` (`Libtmux.Endpoint.t`)
- `session` (`Libtmux.Session.Id.t`)
