1. Wait () and waitpid () function descriptions
Wait ()
Once the process has called wait (), it immediately blocks itself, and the wait automatically parses whether a child process with the current process has exited, and if it finds a child process that has become a zombie, wait collects the child process information and destroys it and returns it. If no such child process is found , wait is blocked here until a child process finishes or the process receives a specified signal.
Waitpid ()
Waitpid () acts like Wait (), but it does not have to wait for the first terminating subprocess, and it has several options, such as providing a non-blocking version of the Wait () feature. In fact, the wait () function is just a special case of the Waitpid () function, and the Waitpid () function is called directly when implementing the Wait () function inside Linux.
The wait () function is implemented:
Static inline pid_t wait (int *wait_stat)
{
Return Waitpid ( -1,wait_stat,0);
}
2. Wait () and waitpid () function format description
(1) The Wait () function is formatted as follows:
(2) the Waitpid () function is formatted as follows
Blocking process functions wait () and Waitpid ()