# LibTmux.Server.runProgram

- **Package:** libtmux-haskell
- **Language:** Haskell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-haskell/blob/72edb54317bf619c6dc54bff311844f062f8984c/src/LibTmux/Server.hs#L377
- **Page:** https://libtmux.org/en/haskell/latest/reference/libtmux-server-v-runprogram/

```haskell
runProgram :: Server -> ProgramOptions -> IO ProgramResult
```

Signature types: [`Server`](/en/haskell/latest/reference/libtmux-server-t-server/), [`ProgramOptions`](/en/haskell/latest/reference/libtmux-program-t-programoptions/), [`IO`](https://hackage.haskell.org/package/base-4.22.0.0/docs/Prelude.html#t:IO), [`ProgramResult`](/en/haskell/latest/reference/libtmux-program-t-programresult/).

Wait for a terminal application, capture its bounded final rendered output,
 and clean up before returning a detached result. Cancellation initiates bounded
 cleanup. Set [`executionTimeout`](/en/haskell/latest/reference/libtmux-program-v-programoptions-executiontimeout/) for an owning setup/observation
 deadline; cleanup has a separate budget. Without it there is no total limit.

## Referenced declarations

- [`LibTmux.Program.ProgramOptions`](/en/haskell/latest/reference/libtmux-program-t-programoptions/) (data type)
- [`LibTmux.Program.ProgramResult`](/en/haskell/latest/reference/libtmux-program-t-programresult/) (data type)
- [`LibTmux.Server.Server`](/en/haskell/latest/reference/libtmux-server-t-server/) (data type)

## tmux command

The tmux commands behind `runProgram`.

- [`capture-pane`](/en/tmux/latest/manual/capture-pane/)
- [`delete-buffer`](/en/tmux/latest/manual/delete-buffer/)
- [`kill-session`](/en/tmux/latest/manual/kill-session/) (when the owned session still exists)
- [`new-session`](/en/tmux/latest/manual/new-session/)
- [`resize-window`](/en/tmux/latest/manual/resize-window/)
- [`save-buffer`](/en/tmux/latest/manual/save-buffer/)
- [`set-option`](/en/tmux/latest/manual/set-option/)
- [`wait-for`](/en/tmux/latest/manual/wait-for/)
- [`display-message`](/en/tmux/latest/manual/display-message/)
- [`has-session`](/en/tmux/latest/manual/has-session/) (when an owned creation receipt was retained)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_capture_pane_entry`](/en/tmux/latest/reference/c-variable-cmd_capture_pane_entry/) (attribute)
- [`cmd_capture_pane_exec`](/en/tmux/latest/reference/c-function-cmd-capture-pane-c-cmd_capture_pane_exec/) (function)
- [`cmd_delete_buffer_entry`](/en/tmux/latest/reference/c-variable-cmd_delete_buffer_entry/) (attribute)
- [`cmd_set_buffer_exec`](/en/tmux/latest/reference/c-function-cmd-set-buffer-c-cmd_set_buffer_exec/) (function)
- [`cmd_kill_session_entry`](/en/tmux/latest/reference/c-variable-cmd_kill_session_entry/) (attribute)
- [`cmd_kill_session_exec`](/en/tmux/latest/reference/c-function-cmd-kill-session-c-cmd_kill_session_exec/) (function)
- [`cmd_new_session_entry`](/en/tmux/latest/reference/c-variable-cmd_new_session_entry/) (attribute)
- [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)
- [`cmd_resize_window_entry`](/en/tmux/latest/reference/c-variable-cmd_resize_window_entry/) (attribute)
- [`cmd_resize_window_exec`](/en/tmux/latest/reference/c-function-cmd-resize-window-c-cmd_resize_window_exec/) (function)
- [`cmd_save_buffer_entry`](/en/tmux/latest/reference/c-variable-cmd_save_buffer_entry/) (attribute)
- [`cmd_save_buffer_exec`](/en/tmux/latest/reference/c-function-cmd-save-buffer-c-cmd_save_buffer_exec/) (function)
- [`cmd_set_option_entry`](/en/tmux/latest/reference/c-variable-cmd_set_option_entry/) (attribute)
- [`cmd_set_option_exec`](/en/tmux/latest/reference/c-function-cmd-set-option-c-cmd_set_option_exec/) (function)
- [`cmd_wait_for_entry`](/en/tmux/latest/reference/c-variable-cmd_wait_for_entry/) (attribute)
- [`cmd_wait_for_exec`](/en/tmux/latest/reference/c-function-cmd-wait-for-c-cmd_wait_for_exec/) (function)
- [`cmd_display_message_entry`](/en/tmux/latest/reference/c-variable-cmd_display_message_entry/) (attribute)
- [`cmd_display_message_exec`](/en/tmux/latest/reference/c-function-cmd-display-message-c-cmd_display_message_exec/) (function)
- [`cmd_has_session_entry`](/en/tmux/latest/reference/c-variable-cmd_has_session_entry/) (attribute)

Each path starts at a function a command runs, which is degree 1. The degree counts steps from there along the path, and each step is a call or a reference: degree 2 is reached from that function, degree 3 from the next, and so on.

### Create a session and its first pane

1. [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)
2. calls → [`spawn_window`](/en/tmux/latest/reference/c-function-spawn_window/) (function)
3. calls → [`spawn_pane`](/en/tmux/latest/reference/c-function-spawn_pane/) (function)
4. calls → [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) (function)
5. calls → [`window_pane_create`](/en/tmux/latest/reference/c-function-window-c-window_pane_create/) (function)

## Guides

Pages that discuss `runProgram`.

### Core

- [tmux client library for Haskell](/en/haskell/latest/core/)

### Guides

- [Run terminal applications](/en/haskell/latest/guides/programs/)
