---
name: "pwait"
section: "1"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/pwait"
---

# pwait(1)

wait for processes to terminate

## NAME

**pwait** – wait for processes to terminate

## SYNOPSIS

**pwait** \[**-t** *duration*\] \[**-oprv**\] *pid* ...

## DESCRIPTION

The **pwait** utility will wait until each of the given processes has terminated.

The following option is available:

- **-o**

  Exit when any of the given processes has terminated.

- **-p**

  On exit, print a list of processes that have not terminated.

- **-r**

  Do not exit until target processes have not only terminated, but been reaped by a call to the [wait(2)](/wait/2.md) family of functions. Without this flag, target processes may still exist as zombies when **pwait** exits. Beware of deadlocks if a target process's reaper (usually its parent) is directly or indirectly blocked by **pwait**.

- **-t** *duration*

  If any process is still running after *duration*, **pwait** will exit. The *duration* value can be integer or decimal numbers. Values without unit symbols are interpreted as seconds.

  Supported unit symbols are:

  - s

    seconds

  - m

    minutes

  - h

    hours

- **-v**

  Print the exit status when each process terminates or ‘timeout’ if the timer goes off earlier.

If **pwait** receives SIGINFO (see the **status** argument for [stty(1)](/stty/1.md)) signal, a space-separated list of processes still being waited on is printed to the standard error output.

## EXIT STATUS

The **pwait** utility exits 0 on success, and \>0 if an error occurs.

If the **-t** flag is specified and a timeout occurs, the exit status will be 124.

Invalid pids elicit a warning message but are otherwise ignored.

## EXAMPLES

Start two [sleep(1)](/sleep/1.md) processes in the background. The first one will sleep for 30 seconds and the second one for one hour. Wait for any of them to finish but no more than 5 seconds. Since a timeout occurs the exit status is 124:

```
$ sleep 30 & sleep 3600 &
[1] 1646
[2] 1647
$ pwait -o -t5 1646 1647
$ echo $?
124
```

Same as above but try to obtain the exit status of the processes. In this case ‘timeout’ is shown and the exit status is 124:

```
$ sleep 30 & sleep 3600 &
[1] 1652
[2] 1653
$ pwait -v -t 5 1652 1653
timeout
$ echo $?
124
```

Start two [sleep(1)](/sleep/1.md) processes in the background sleeping for 30 and 40 seconds respectively. Wait 60 seconds for any of them to finish and get their exit codes:

```
$ sleep 30 & sleep 40 &
[1] 1674
[2] 1675
$ pwait -v -t 60 1674 1675
1674: exited with status 0.
[1]-  Done                    sleep 30
1675: exited with status 0.
[2]+  Done                    sleep 40
$ echo $?
0
```

## SEE ALSO

[kill(1)](/kill/1.md), [pkill(1)](/pkill/1.md), [ps(1)](/ps/1.md), [stty(1)](/stty/1.md), [wait(1)](/wait/1.md), [kqueue(2)](/kqueue/2.md)

## NOTES

**pwait** is not a substitute for the [wait(1)](/wait/1.md) builtin as it will not clean up any zombies or state in the parent process.

To avoid deadlock, **pwait** will ignore its own pid, if it is provided as a process id to wait for.

## HISTORY

A **pwait** command first appeared in SunOS 5.8.
