# spawn_pane

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L201
- **Page:** https://libtmux.org/en/tmux/latest/reference/c-function-spawn_pane/

```c
struct window_pane * spawn_pane(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/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) — calls → [`spawn_window`](/en/tmux/latest/reference/c-function-spawn_window/) — calls → [`spawn_pane`](/en/tmux/latest/reference/c-function-spawn_pane/) — calls → [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) — calls → [`window_pane_create`](/en/tmux/latest/reference/c-function-window-c-window_pane_create/)

### Split a window

[`cmd_split_window_exec`](/en/tmux/latest/reference/c-function-cmd-split-window-c-cmd_split_window_exec/) — references → [`spawn_pane`](/en/tmux/latest/reference/c-function-spawn_pane/) — calls → [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) — calls → [`window_pane_create`](/en/tmux/latest/reference/c-function-window-c-window_pane_create/)

## Called by

- [`cmd_respawn_pane_exec`](/en/tmux/latest/reference/c-function-cmd-respawn-pane-c-cmd_respawn_pane_exec/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/cmd-respawn-pane.c#L81)
- [`spawn_window`](/en/tmux/latest/reference/c-function-spawn_window/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L170)

## Calls

- [`checkshell`](/en/tmux/latest/reference/c-function-checkshell/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L343)
- [`cmd_copy_argv`](/en/tmux/latest/reference/c-function-cmd_copy_argv/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L318)
- [`cmd_free_argv`](/en/tmux/latest/reference/c-function-cmd_free_argv/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L316)
- [`cmd_log_argv`](/en/tmux/latest/reference/c-function-cmd_log_argv/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L358)
- [`cmd_stringify_argv`](/en/tmux/latest/reference/c-function-cmd_stringify_argv/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L353)
- [`cmdq_get_client`](/en/tmux/latest/reference/c-function-cmdq_get_client/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L205)
- [`cmdq_get_target`](/en/tmux/latest/reference/c-function-cmdq_get_target/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L204)
- [`environ_copy`](/en/tmux/latest/reference/c-function-environ_copy/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L324)
- [`environ_find`](/en/tmux/latest/reference/c-function-environ_find/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L333)
- [`environ_for_session`](/en/tmux/latest/reference/c-function-environ_for_session/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L322)
- [`environ_free`](/en/tmux/latest/reference/c-function-environ_free/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L401)
- [`environ_log`](/en/tmux/latest/reference/c-function-environ_log/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L359)
- [`environ_push`](/en/tmux/latest/reference/c-function-environ_push/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L457)
- [`environ_set`](/en/tmux/latest/reference/c-function-environ_set/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L325)
- [`fdforkpty`](/en/tmux/latest/reference/c-function-fdforkpty/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L391)
- [`find_home`](/en/tmux/latest/reference/c-function-find_home/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L213)
- [`format_single`](/en/tmux/latest/reference/c-function-format_single/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L230)
- [`input_free`](/en/tmux/latest/reference/c-function-input_free/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L262)
- [`layout_assign_pane`](/en/tmux/latest/reference/c-function-layout_assign_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L273)
- [`layout_close_pane`](/en/tmux/latest/reference/c-function-layout_close_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L397)
- [`layout_init`](/en/tmux/latest/reference/c-function-layout_init/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L269)
- [`log_close`](/en/tmux/latest/reference/c-function-log_close/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L456)
- [`log_debug`](/en/tmux/latest/reference/c-function-log_debug/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L351)
- [`notify_window`](/en/tmux/latest/reference/c-function-notify_window/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L516)
- [`options_get_number`](/en/tmux/latest/reference/c-function-options_get_number/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L247)
- [`options_get_string`](/en/tmux/latest/reference/c-function-options_get_string/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L294)
- [`proc_clear_signals`](/en/tmux/latest/reference/c-function-proc_clear_signals/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L453)
- [`screen_reinit`](/en/tmux/latest/reference/c-function-screen_reinit/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L261)
- [`server_client_remove_pane`](/en/tmux/latest/reference/c-function-server_client_remove_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L396)
- [`spawn_log`](/en/tmux/latest/reference/c-function-spawn-c-spawn_log/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L223)
- [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L268)
- [`window_pane_index`](/en/tmux/latest/reference/c-function-window_pane_index/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L250)
- [`window_pane_reset_mode_all`](/en/tmux/latest/reference/c-function-window_pane_reset_mode_all/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L260)
- [`window_pane_set_event`](/en/tmux/latest/reference/c-function-window_pane_set_event/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L503)
- [`window_remove_pane`](/en/tmux/latest/reference/c-function-window_remove_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L398)
- [`window_set_active_pane`](/en/tmux/latest/reference/c-function-window_set_active_pane/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L511)
- [`xasprintf`](/en/tmux/latest/reference/c-function-xasprintf/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L232)
- [`xstrdup`](/en/tmux/latest/reference/c-function-xstrdup/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/spawn.c#L239)

## Other function references

- [`server_client_get_cwd`](/en/tmux/latest/reference/c-function-server_client_get_cwd/) (function)

## Referenced by

- [`cmd_split_window_exec`](/en/tmux/latest/reference/c-function-cmd-split-window-c-cmd_split_window_exec/) (function)

## Referenced declarations

- [`_PATH_BSHELL`](/en/tmux/latest/reference/c-define-compat-h-_path_bshell/) (constant)
- [`_PATH_DEFPATH`](/en/tmux/latest/reference/c-define-compat-h-_path_defpath/) (constant)
- [`window.active`](/en/tmux/latest/reference/c-struct-window-active/) (attribute)
- [`spawn_context.argc`](/en/tmux/latest/reference/c-struct-spawn_context-argc/) (attribute)
- [`window_pane.argc`](/en/tmux/latest/reference/c-struct-window_pane-argc/) (attribute)
- [`spawn_context.argv`](/en/tmux/latest/reference/c-struct-spawn_context-argv/) (attribute)
- [`window_pane.argv`](/en/tmux/latest/reference/c-struct-window_pane-argv/) (attribute)
- [`window_pane.base`](/en/tmux/latest/reference/c-struct-window_pane-base/) (attribute)
- [`spawn_context.cwd`](/en/tmux/latest/reference/c-struct-spawn_context-cwd/) (attribute)
- [`window_pane.cwd`](/en/tmux/latest/reference/c-struct-window_pane-cwd/) (attribute)
- [`client.environ`](/en/tmux/latest/reference/c-struct-client-environ/) (attribute)
- [`spawn_context.environ`](/en/tmux/latest/reference/c-struct-spawn_context-environ/) (attribute)
- [`window_pane.event`](/en/tmux/latest/reference/c-struct-window_pane-event/) (attribute)
- [`window_pane.fd`](/en/tmux/latest/reference/c-struct-window_pane-fd/) (attribute)
- [`layout_cell.flags`](/en/tmux/latest/reference/c-struct-layout_cell-flags/) (attribute)
- [`spawn_context.flags`](/en/tmux/latest/reference/c-struct-spawn_context-flags/) (attribute)
- [`window_pane.flags`](/en/tmux/latest/reference/c-struct-window_pane-flags/) (attribute)
- [`window.flags`](/en/tmux/latest/reference/c-struct-window-flags/) (attribute)
- [`global_options`](/en/tmux/latest/reference/c-variable-global_options/) (attribute)
- [`window_pane.ictx`](/en/tmux/latest/reference/c-struct-window_pane-ictx/) (attribute)
- [`window_pane.id`](/en/tmux/latest/reference/c-struct-window_pane-id/) (attribute)
- [`winlink.idx`](/en/tmux/latest/reference/c-struct-winlink-idx/) (attribute)
- [`spawn_context.item`](/en/tmux/latest/reference/c-struct-spawn_context-item/) (attribute)
- [`window_pane.layout_cell`](/en/tmux/latest/reference/c-struct-window_pane-layout_cell/) (attribute)
- [`LAYOUT_CELL_FLOATING`](/en/tmux/latest/reference/c-define-tmux-h-layout_cell_floating/) (constant)
- [`spawn_context.lc`](/en/tmux/latest/reference/c-struct-spawn_context-lc/) (attribute)
- [`screen.mode`](/en/tmux/latest/reference/c-struct-screen-mode/) (attribute)
- [`MODE_CRLF`](/en/tmux/latest/reference/c-define-tmux-h-mode_crlf/) (constant)
- [`MODE_CURSOR`](/en/tmux/latest/reference/c-define-tmux-h-mode_cursor/) (constant)
- [`session.name`](/en/tmux/latest/reference/c-struct-session-name/) (attribute)
- [`session.options`](/en/tmux/latest/reference/c-struct-session-options/) (attribute)
- [`PANE_EMPTY`](/en/tmux/latest/reference/c-define-tmux-h-pane_empty/) (constant)
- [`PANE_EXITED`](/en/tmux/latest/reference/c-define-tmux-h-pane_exited/) (constant)
- [`PANE_STATUSDRAWN`](/en/tmux/latest/reference/c-define-tmux-h-pane_statusdrawn/) (constant)
- [`PANE_STATUSREADY`](/en/tmux/latest/reference/c-define-tmux-h-pane_statusready/) (constant)
- [`window_pane.pid`](/en/tmux/latest/reference/c-struct-window_pane-pid/) (attribute)
- [`ptm_fd`](/en/tmux/latest/reference/c-variable-ptm_fd/) (attribute)
- [`cmd_find_state.s`](/en/tmux/latest/reference/c-struct-cmd_find_state-s/) (attribute)
- [`spawn_context.s`](/en/tmux/latest/reference/c-struct-spawn_context-s/) (attribute)
- [`window_pane.saved_layout_cell`](/en/tmux/latest/reference/c-struct-window_pane-saved_layout_cell/) (attribute)
- [`screen_size_x`](/en/tmux/latest/reference/c-define-tmux-h-screen_size_x/) (constant)
- [`screen_size_y`](/en/tmux/latest/reference/c-define-tmux-h-screen_size_y/) (constant)
- [`server_proc`](/en/tmux/latest/reference/c-variable-server_proc/) (attribute)
- [`client.session`](/en/tmux/latest/reference/c-struct-client-session/) (attribute)
- [`window_pane.shell`](/en/tmux/latest/reference/c-struct-window_pane-shell/) (attribute)
- [`spawn_context`](/en/tmux/latest/reference/c-struct-spawn_context/) (struct)
- [`SPAWN_DETACHED`](/en/tmux/latest/reference/c-define-tmux-h-spawn_detached/) (constant)
- [`SPAWN_EMPTY`](/en/tmux/latest/reference/c-define-tmux-h-spawn_empty/) (constant)
- [`SPAWN_FLOATING`](/en/tmux/latest/reference/c-define-tmux-h-spawn_floating/) (constant)
- [`SPAWN_KILL`](/en/tmux/latest/reference/c-define-tmux-h-spawn_kill/) (constant)
- [`SPAWN_NONOTIFY`](/en/tmux/latest/reference/c-define-tmux-h-spawn_nonotify/) (constant)
- [`SPAWN_RESPAWN`](/en/tmux/latest/reference/c-define-tmux-h-spawn_respawn/) (constant)
- [`SPAWN_ZOOM`](/en/tmux/latest/reference/c-define-tmux-h-spawn_zoom/) (constant)
- [`session.tio`](/en/tmux/latest/reference/c-struct-session-tio/) (attribute)
- [`window_pane.tty`](/en/tmux/latest/reference/c-struct-window_pane-tty/) (attribute)
- [`environ_entry.value`](/en/tmux/latest/reference/c-struct-environ_entry-value/) (attribute)
- [`winlink.window`](/en/tmux/latest/reference/c-struct-winlink-window/) (attribute)
- [`window_pane`](/en/tmux/latest/reference/c-struct-window_pane/) (struct)
- [`WINDOW_ZOOMED`](/en/tmux/latest/reference/c-define-tmux-h-window_zoomed/) (constant)
- [`spawn_context.wl`](/en/tmux/latest/reference/c-struct-spawn_context-wl/) (attribute)
- [`spawn_context.wp0`](/en/tmux/latest/reference/c-struct-spawn_context-wp0/) (attribute)
- [`window.xpixel`](/en/tmux/latest/reference/c-struct-window-xpixel/) (attribute)
- [`window.ypixel`](/en/tmux/latest/reference/c-struct-window-ypixel/) (attribute)
