waitpid(3)
DESCRIPTION
Waits for a selected child and translates the direct waitpid result into the libc −1 and errno convention. Positive pid selects one child; zero selects the caller's process group; −1 selects any child; and a negative value selects a process group.
SYNOPSIS
#include <sys/wait.h> int waitpid(int pid, int *status, int options);
RETURN VALUE
- Returns the reaped or reported child PID, zero only with WNOHANG when no event is ready, or -1 and sets errno.
ERRORS
-EFAULT- Status is non‑null but not writable.
-ECHILD- No matching child exists.
-EINVAL- Pid or options is invalid.
-ESRCH- The calling process or thread does not exist.
NOTES
The only accepted flags are WNOHANG, WUNTRACED, and WCONTINUED. WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG, and WIFCONTINUED interpret the status word emitted by the kernel.