# program.Program.wait

- **Module:** program
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/program.ts#L69
- **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[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
pane killed from outside fires no event, so the wait reads its pane every
second and raises [`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/) within about a second of the kill.

## Examples

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

## Parameters

- `options?` (`ProgramWaitOptions`)
