Linux Multi-task programming (vi) writing multiple process programs and their code

Source: Internet
Author: User

Experimental purposes

By writing a multiple process program, you are proficient in the use of functions such as fork (), exec (), wait (), and Waitpid () to further understand the procedures for multiple process programming in Linux.

Experimental content

The experiment has 3 processes, one of which is the parent process, and the remaining two are the child processes created by the parent process, one of which runs the "ls-l" instruction and the other subprocess quits unexpectedly after 5s is paused. The parent process waits for the end of the first process to be blocked, then waits for the exit of another subprocess in a non-blocking manner, and the parent process returns after the message that the 2nd child process ends.

Experiment steps

The flow chart of the experiment is as follows

Experimental source code

First look at the following code, this program can get the results we want? How many processes will it run?

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.