Blocking process functions wait () and Waitpid ()

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.