# spawn_window

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L75
- **Page:** https://libtmux.org/en/tmux/3.2a/reference/c-function-spawn_window/

```c
struct winlink * spawn_window(struct spawn_context *sc, char **cause)
```

## Parameters

- `sc` (`struct spawn_context *`)
- `cause` (`char **`)

## Paths through the source

Arrows name source relationships, not a runtime execution order.

### Create a session and its first pane

[`cmd_new_session_exec`](/en/tmux/3.2a/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) — calls → [`spawn_window`](/en/tmux/3.2a/reference/c-function-spawn_window/) — calls → [`spawn_pane`](/en/tmux/3.2a/reference/c-function-spawn_pane/) — calls → [`window_add_pane`](/en/tmux/3.2a/reference/c-function-window_add_pane/) — calls → [`window_pane_create`](/en/tmux/3.2a/reference/c-function-window-c-window_pane_create/)

## Called by

- [`cmd_new_session_exec`](/en/tmux/3.2a/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/cmd-new-session.c#L283)
- [`cmd_respawn_window_exec`](/en/tmux/3.2a/reference/c-function-cmd-respawn-window-c-cmd_respawn_window_exec/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/cmd-respawn-window.c#L84)

## Calls

- [`cmdq_get_client`](/en/tmux/3.2a/reference/c-function-cmdq_get_client/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L78)
- [`default_window_name`](/en/tmux/3.2a/reference/c-function-default_window_name/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L185)
- [`default_window_size`](/en/tmux/3.2a/reference/c-function-default_window_size/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L154)
- [`format_single`](/en/tmux/3.2a/reference/c-function-format_single/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L181)
- [`layout_free`](/en/tmux/3.2a/reference/c-function-layout_free/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L109)
- [`layout_init`](/en/tmux/3.2a/reference/c-function-layout_init/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L115)
- [`notify_session_window`](/en/tmux/3.2a/reference/c-function-notify_session_window/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L135)
- [`options_set_number`](/en/tmux/3.2a/reference/c-function-options_set_number/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L183)
- [`session_group_synchronize_from`](/en/tmux/3.2a/reference/c-function-session_group_synchronize_from/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L196)
- [`session_select`](/en/tmux/3.2a/reference/c-function-session_select/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L190)
- [`spawn_log`](/en/tmux/3.2a/reference/c-function-spawn-c-spawn_log/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L86)
- [`spawn_pane`](/en/tmux/3.2a/reference/c-function-spawn_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L171)
- [`window_destroy_panes`](/en/tmux/3.2a/reference/c-function-window_destroy_panes/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L110)
- [`window_set_active_pane`](/en/tmux/3.2a/reference/c-function-window_set_active_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L116)
- [`winlink_find_by_index`](/en/tmux/3.2a/reference/c-function-winlink_find_by_index/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L124)
- [`winlink_remove`](/en/tmux/3.2a/reference/c-function-winlink_remove/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L137)
- [`winlink_set_window`](/en/tmux/3.2a/reference/c-function-winlink_set_window/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L165)
- [`winlink_stack_remove`](/en/tmux/3.2a/reference/c-function-winlink_stack_remove/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L136)
- [`xasprintf`](/en/tmux/3.2a/reference/c-function-xasprintf/) (function) [Call site](https://github.com/tmux/tmux/blob/3b929f332aafa7f1080eacc31feb11ffbb1d1841/spawn.c#L100)

## Other function references

- [`options_get_number`](/en/tmux/3.2a/reference/c-function-options_get_number/) (function)
- [`window_create`](/en/tmux/3.2a/reference/c-function-window_create/) (function)
- [`winlink_add`](/en/tmux/3.2a/reference/c-function-winlink_add/) (function)

## Referenced by

- [`cmd_new_window_exec`](/en/tmux/3.2a/reference/c-function-cmd-new-window-c-cmd_new_window_exec/) (function)

## Referenced declarations

- [`session.curw`](/en/tmux/3.2a/reference/c-struct-session-curw/) (attribute)
- [`winlink.entry`](/en/tmux/3.2a/reference/c-struct-winlink-entry/) (attribute)
- [`window_pane.fd`](/en/tmux/3.2a/reference/c-struct-window_pane-fd/) (attribute)
- [`spawn_context.flags`](/en/tmux/3.2a/reference/c-struct-spawn_context-flags/) (attribute)
- [`winlink.flags`](/en/tmux/3.2a/reference/c-struct-winlink-flags/) (attribute)
- [`spawn_context.idx`](/en/tmux/3.2a/reference/c-struct-spawn_context-idx/) (attribute)
- [`winlink.idx`](/en/tmux/3.2a/reference/c-struct-winlink-idx/) (attribute)
- [`spawn_context.item`](/en/tmux/3.2a/reference/c-struct-spawn_context-item/) (attribute)
- [`session.lastw`](/en/tmux/3.2a/reference/c-struct-session-lastw/) (attribute)
- [`window.latest`](/en/tmux/3.2a/reference/c-struct-window-latest/) (attribute)
- [`session.name`](/en/tmux/3.2a/reference/c-struct-session-name/) (attribute)
- [`spawn_context.name`](/en/tmux/3.2a/reference/c-struct-spawn_context-name/) (attribute)
- [`window.name`](/en/tmux/3.2a/reference/c-struct-window-name/) (attribute)
- [`session.options`](/en/tmux/3.2a/reference/c-struct-session-options/) (attribute)
- [`window.options`](/en/tmux/3.2a/reference/c-struct-window-options/) (attribute)
- [`window.panes`](/en/tmux/3.2a/reference/c-struct-window-panes/) (attribute)
- [`spawn_context.s`](/en/tmux/3.2a/reference/c-struct-spawn_context-s/) (attribute)
- [`winlink.session`](/en/tmux/3.2a/reference/c-struct-winlink-session/) (attribute)
- [`spawn_context`](/en/tmux/3.2a/reference/c-struct-spawn_context/) (struct)
- [`SPAWN_DETACHED`](/en/tmux/3.2a/reference/c-define-tmux-h-spawn_detached/) (constant)
- [`SPAWN_KILL`](/en/tmux/3.2a/reference/c-define-tmux-h-spawn_kill/) (constant)
- [`SPAWN_NONOTIFY`](/en/tmux/3.2a/reference/c-define-tmux-h-spawn_nonotify/) (constant)
- [`SPAWN_RESPAWN`](/en/tmux/3.2a/reference/c-define-tmux-h-spawn_respawn/) (constant)
- [`window.sx`](/en/tmux/3.2a/reference/c-struct-window-sx/) (attribute)
- [`window.sy`](/en/tmux/3.2a/reference/c-struct-window-sy/) (attribute)
- [`spawn_context.tc`](/en/tmux/3.2a/reference/c-struct-spawn_context-tc/) (attribute)
- [`winlink.window`](/en/tmux/3.2a/reference/c-struct-winlink-window/) (attribute)
- [`session.windows`](/en/tmux/3.2a/reference/c-struct-session-windows/) (attribute)
- [`winlink`](/en/tmux/3.2a/reference/c-struct-winlink/) (struct)
- [`WINLINK_ALERTFLAGS`](/en/tmux/3.2a/reference/c-define-tmux-h-winlink_alertflags/) (constant)
- [`spawn_context.wl`](/en/tmux/3.2a/reference/c-struct-spawn_context-wl/) (attribute)
- [`spawn_context.wp0`](/en/tmux/3.2a/reference/c-struct-spawn_context-wp0/) (attribute)
