# pane.Pane.waitForExit

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

```
waitForExit(
  options?: ProgramWaitOptions,
): Promise<ProgramExit>
```

Resolve with how this pane's program ended, whoever started it.

At once for a pane already dead under [`remain-on-exit`](/en/tmux/latest/catalog/options/remain-on-exit/); otherwise when
tmux reports the exit, with the status a closing pane takes with it.
A signal that ended the pane's process shows as [`signalCode`](/en/ts/latest/reference/types-programexit-signalcode/) with `exitCode`
null.
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, which fires no event, raises
[`ObjectNotFoundError`](/en/ts/latest/reference/errors-objectnotfounderror/) within about two seconds: one to notice, and
one for the event a closing pane fires to arrive.

Requires tmux 3.8 or newer.

## Examples

```ts
const build = await window.split({ shellCommand: "sleep 1; exit 3" });
const exit = await build.waitForExit({ timeoutMs: 10_000 });
exit.exitCode; // 3
```

## Parameters

- `options?` (`ProgramWaitOptions`)
