A process waits for a child with waitpid(pid, &status, 0), which blocks until that child has ended and returns its PID; wait(&status) does the same for any child. The integer status encodes how the child ended: WIFEXITED(status) is true when it ended by returning from main or calling exit, and WEXITSTATUS(status) is then the low 8 bits of its exit status; WIFSIGNALED(status) is true when a signal killed it, and WTERMSIG(status) is the signal’s number.
Computer Science · Glossaire