Fork introduction:Fork stands for the meaning of "branching and branching". In the operating system, fork is a famous Unix (or Unix-like, such as Linux or minix) to create a sub-process.
[Note1]What is the role of Fork? In other words, what is the
Fork introduction:Fork stands for the meaning of "branching and branching". In the operating system, fork is a famous Unix (or Unix-like, such as Linux or minix) to create a sub-process.
[Note1]What is the role of Fork? In other words, what is the
(1) Fork system call DescriptionThe fork system call is used to create a new process from an existing process called a child process, and the original process is called the parent process. The fork is called once, returned two times, and the two
1.pid_t Fork ();(1) When a process calls fork, the system creates a child process. This child process differs from the parent process in that it has only his process ID and parent process ID, and the others are the same. It's like a process clone
In Unix systems, the only way to create a new process is to call the fork system. The process called fork is called the parent process, and the newly created process is called the child process. Syntax format of system call:
PID = fork ();
When
After using fork, you may need to get the health of the fork's process, such as there is no exception, crash.The key description of wait in man is as follows:All of these system calls is used to wait for state changes in a child of the calling
Fork () function function--Create a new process1. The parent-child process has separate data segments, heaps, stacks, shared code segmentsEach process in Linux has a 4G virtual address space (separate 3G user space and shared 1G kernel space), and
Lien0000342014-10-07
In the process control trilogy, we learned that fork is the first part of the trilogy to create a new process. However, we haven't covered much more in-depth information about fork, such as the relationship between new processes
int status;pid_t t = fork (), if (t) {waitpid (T, &status, 0);} else{System ("VI temp.txt"); Exit (0);} After both the parent and child processes have finished executing the parsing process: if and else or select branch.The main reason is that
1.pid_t Fork ();(1) When a process calls fork, a child process is created. This subprocess differs from the parent process only by his process ID and the parent process ID, and the rest are the same. Just like the character process clone (clone)
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.