# program.Program

- **Module:** program
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** class
- **Source:** https://github.com/libtmux/libtmux-ts/blob/ad09eaef7ffff40f510989ee0695852c44a31576/packages/libtmux/src/program.ts#L23
- **Page:** https://libtmux.org/en/ts/latest/reference/program-program/

A program started by [`Server.spawn`](/en/ts/latest/reference/server-server-spawn/), running in a pane of its own.

Drive a full-screen program with [`Pane.sendKeys`](/en/ts/latest/reference/pane-pane-sendkeys/) and read its screen
with [`Pane.capture`](/en/ts/latest/reference/pane-pane-capture/).

It owns its pane. [`Program.kill`](/en/ts/latest/reference/program-program-kill/), or leaving an `await using` scope,
ends the program and removes the pane, unless spawned with [`keep`](/en/ts/latest/reference/types-spawnoptions-keep/). Should
this process exit or die first, tmux ends the program through its lease,
unless spawned with `orphanAfterMs: null`. A kill ends a stream in progress
with [`LibTmuxError`](/en/ts/latest/reference/errors-libtmuxerror/), and a pane removed from outside with
[`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/). After [`kill`](/en/ts/latest/reference/program-program-kill/), [`output`](/en/ts/latest/reference/program-program-output/) raises
[`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/), [`stream`](/en/ts/latest/reference/program-program-stream/) raises [`LibTmuxError`](/en/ts/latest/reference/errors-libtmuxerror/), and
[`wait`](/en/ts/latest/reference/program-program-wait/) returns the exit it already saw or raises [`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/).

Requires tmux 3.8 or newer.

## Members

### Common operations

- [`[Symbol.asyncDispose]`](/en/ts/latest/reference/program-program-[symbol-asyncdispose]/) (method): Kill the program when an `await using` scope ends.
- [`kill`](/en/ts/latest/reference/program-program-kill/) (method): End the program and remove its pane, unless kept.
- [`output`](/en/ts/latest/reference/program-program-output/) (method): What the program has printed so far, as its terminal shows it.
- [`pane`](/en/ts/latest/reference/program-program-pane/) (attribute): The pane the program runs in.
- [`sessionName`](/en/ts/latest/reference/program-program-sessionname/) (attribute): The session the program runs in: a detached one of its own, removed with it, or with `from` that pane's session, which loses only the program's window or split. `tmux attach -t` it to watch the program.
- [`stream`](/en/ts/latest/reference/program-program-stream/) (method): Everything the program writes, as UTF-8 text in the order it was written, until it exits and its last write has arrived.
- [`wait`](/en/ts/latest/reference/program-program-wait/) (method): Resolve with how the program ended, once it has. The pane stays, for {@link Program.output}, until {@link Program.kill} or `await using`. A program that never ran, because `argv[0]` was not found or is not executable, or `startDirectory` could not be entered, rejects every wait with {@link ProgramStartError}, and its stream ends with it.

### Other members

- [`constructor`](/en/ts/latest/reference/program-program-constructor/) (method)
- [`programBrand`](/en/ts/latest/reference/program-program-programbrand/) (attribute)
