# session_attach

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L323
- **Page:** https://libtmux.org/en/tmux/3.7c/reference/c-function-session_attach/

```c
struct winlink * session_attach(struct session *s, struct window *w, int idx, char **cause)
```

## Parameters

- `s` (`struct session *`)
- `w` (`struct window *`)
- `idx` (`int`)
- `cause` (`char **`)

## Called by

- [`cmd_break_pane_exec`](/en/tmux/3.7c/reference/c-function-cmd-break-pane-c-cmd_break_pane_exec/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/cmd-break-pane.c#L132)
- [`server_link_window`](/en/tmux/3.7c/reference/c-function-server_link_window/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/server-fn.c#L291)

## Calls

- [`notify_session_window`](/en/tmux/3.7c/reference/c-function-notify_session_window/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L333)
- [`session_group_synchronize_from`](/en/tmux/3.7c/reference/c-function-session_group_synchronize_from/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L335)
- [`winlink_set_window`](/en/tmux/3.7c/reference/c-function-winlink_set_window/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L332)
- [`xasprintf`](/en/tmux/3.7c/reference/c-function-xasprintf/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L328)

## Other function references

- [`winlink_add`](/en/tmux/3.7c/reference/c-function-winlink_add/) (function)

## Referenced declarations

- [`winlink.idx`](/en/tmux/3.7c/reference/c-struct-winlink-idx/) (attribute)
- [`session`](/en/tmux/3.7c/reference/c-struct-session/) (struct)
- [`winlink.session`](/en/tmux/3.7c/reference/c-struct-winlink-session/) (attribute)
- [`window`](/en/tmux/3.7c/reference/c-struct-window/) (struct)
- [`session.windows`](/en/tmux/3.7c/reference/c-struct-session-windows/) (attribute)
- [`winlink`](/en/tmux/3.7c/reference/c-struct-winlink/) (struct)
