Wait () and Waitpid ()
Function description
The wait () function is used to block the parent process (that is, the process that invokes the ()) until a child process finishes or the process receives a specified signal. The wait () function returns immediately if the parent process has no child processes or its child processes have ended.
The role of Waitpid () is the same as wait (), but it is not necessarily waiting for the first aborted subprocess (it can specify the subprocess that needs to wait to terminate), and it has several options, such as providing a non-blocking version of the Waiting () function and supporting job control. In fact, the wait () function is just a special case of the Waitpid () function, which is directly called the Waitpid () function when implementing the wait () function inside Linux.
function format
The following figure is the format of the wait () function
The following figure is the format for the Waitpid () function