O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Waiting for Process Completion

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? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required