# program.Program.wait

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

```
wait(options?: ProgramWaitOptions): Promise<ProgramExit>
```

Resolve with how the program ended, once it has. The pane stays, for [`Program.output`](/en/ts/latest/reference/program-program-output/), until [`Program.kill`](/en/ts/latest/reference/program-program-kill/) or `await using`. A program that never ran, because [`argv`](/en/ts/latest/reference/types-plannedoperation-argv/)`[0]` was not found or is not executable, or `startDirectory` could not be entered, rejects every wait with [`ProgramStartError`](/en/ts/latest/reference/errors-programstarterror/), and its stream ends with it.

Giving up leaves the program running: a timeout throws
[`WaitTimeoutError`](/en/ts/latest/reference/errors-waittimeouterror/) and an abort throws [`TmuxTransportError`](/en/ts/latest/reference/errors-tmuxtransporterror/)
of kind `cancelled`; with neither it waits as long as the program runs. A
program whose pane is killed from outside raises
[`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/) at the next read of its pane, within about a
second.

## Examples

```ts
await using program = await server.spawn(["sh", "-c", "exit 3"]);
(await program.wait()).exitCode; // 3
```

## Parameters

- `options?` (`ProgramWaitOptions`)
