The example program of Listing 19.1 simply called upon sleep(3) to pause its execution until the other process had time to execute. A better method would be to have the parent process wait until the child process completes.
Other parent programs may continue to execute after starting several different child processes over time. Consequently, these processes need to be able to inquire about the child process's termination at some point.
The UNIX kernel provides the wait(2) family of system calls to allow a process to wait for the completion of a child process. Furthermore, these wait(2) system calls permit the parent process to answer the following questions:
What was the process exit code?
Did the process exit normally? ...