# LibTmux::Server#attach

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Ruby
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ruby/blob/da7b6191b9439e3c84fa1c9eeaa9168263ee7af4/gems/libtmux/lib/libtmux/terminal.rb#L47
- **Page:** https://libtmux.org/en/ruby/v0.1.1/reference/libtmux-server-attach/

```
def attach: (
  session: ::LibTmux::EntityRef,
  terminal: ::IO,
  term: ::String,
  ?read_only: bool,
  ?timeout: ::Numeric?,
  ?cancel: untyped
) -> ::LibTmux::TerminalResult
```

Blocks until the owned interactive client exits. The caller supplies and
retains its TTY. Cancellation detaches this client, not pane commands.

Behavior contract: Terminal attachment.

## Parameters

- `session` (`::LibTmux::EntityRef`)
- `terminal` (`::IO`)
- `term` (`::String`)
- `read_only` (`bool`)
- `timeout` (`::Numeric?`)
- `cancel` (`untyped`)

## Raises

- `ArgumentError`

## tmux command

The tmux commands behind `attach`.

- [`attach-session`](/en/tmux/latest/manual/attach-session/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_attach_session_entry`](/en/tmux/latest/reference/c-variable-cmd_attach_session_entry/) (attribute)
- [`cmd_attach_session_exec`](/en/tmux/latest/reference/c-function-cmd-attach-session-c-cmd_attach_session_exec/) (function)
