---
name: "wait"
section: "3"
platform: "linux"
package: "qmail"
version: "1.06-6.2~deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/wait/3"
---

# wait(3)

check child process status

## NAME

wait - check child process status

## SYNTAX

**#include \<wait.h\>**

int **wait\_nohang**(&*wstat*);\
 int **wait\_stop**(&*wstat*);\
 int **wait\_stopnohang**(&*wstat*);\
 int **wait\_pid**(&*wstat*,*pid*);

int **wait\_exitcode**(*wstat*);\
 int **wait\_crashed**(*wstat*);\
 int **wait\_stopped**(*wstat*);\
 int **wait\_stopsig**(*wstat*);

int *pid*;\
 int *wstat*;

## DESCRIPTION

**wait\_nohang** looks for zombies (child processes that have exited). If it sees a zombie, it eliminates the zombie, puts the zombie's exit status into *wstat*, and returns the zombie's process ID. If there are several zombies, **wait\_nohang** picks one. If there are children but no zombies, **wait\_nohang** returns 0. If there are no children, **wait\_nohang** returns -1, setting **errno** appropriately.

**wait\_stopnohang** is similar to **wait\_nohang**, but it also looks for children that have stopped.

**wait\_stop** is similar to **wait\_stopnohang**, but if there are children it will pause waiting for one of them to stop or exit.

**wait\_pid** waits for child process *pid* to exit. It eliminates any zombie that shows up in the meantime, discarding the exit status.

**wait\_stop** and **wait\_pid** retry upon **error\_intr**.

## STATUS PARSING

If the child stopped, **wait\_stopped** is nonzero; **wait\_stopsig** is the signal that caused the child to stop.

If the child exited by crashing, **wait\_stopped** is zero; **wait\_crashed** is nonzero.

If the child exited normally, **wait\_stopped** is zero; **wait\_crashed** is zero; and **wait\_exitcode** is the child's exit code.

## SEE ALSO

[wait(2)](/wait/2.md), [error(3)](/error/3.md)
