Three methods of process generation: fork, system, and exec

Source: Internet
Author: User

1. fork () method

The fork () function copies a process based on the parent process. Its ID number is different from that of the parent process. In a Linux environment, fork () is implemented by writing and copying, with only memory and other features different from the parent process. Others are shared with the parent process. Only after the parent process or child process is modified, to generate a new copy.

2. system () method

The system () function calls the "/bin/sh-c command" to execute a specific command (refer to the http://www.cnblogs.com/nufangrensheng/p/3512291.html) and blocks the current process until the command execution is complete.

3. exec () Mode

When fork and system functions are used, a new process will be created in the system to execute the caller's operation, and the original process will still exist until the user exits explicitly; the exec family functions are different from the previous fork and system functions. The exec family functions replace the original process with the new process, and the system runs from the new process, the PID value of the new process is the same as that of the original process.

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.