The wait system call
In this section we shall see how the wait() system call works
Observe the code below carefully and predict the output
Outputs
As it turns out, we get different outputs each time. Example:
The last output occurs when the main thread gets terminated before the child process. In order to prevent this and always get the first output, we need to stop the execution of the main thread till the child process is running.
This is where the wait() system call comes in
Last updated