A fork system call generates a new process called a sub-process, which is a complex process called.
Product. The Calling process is called the parent process. The child process inherits almost all of the parent processes.
Actual uid, GID and valid uid, GID.
. Environment variable.
. Add GID.
. The flag to close when exec () is called.
. Uid Setting Mode bit.
. GID sets the bitwise of the mode.
. Process Group number.
. Session ID.
. Control terminal.
. Current working directory.
. Root directory.
. File Creation mask umask.
. File length limit ulimit.
. Pre-value, such as priority and any other process pre-parameter, depending on the type
Decide whether to inherit.
. There are some other attributes.
However, sub-processes have different attributes from parent processes:
. Process number. The sub-process number is different from the process group number of any activity.
. Parent process number.
When a child process inherits the file descriptor or stream of the parent process, it has its own copy
And share the resource with the parent process and other child processes.
The user time and system time of the sub-process are initialized to 0.
The timeout clock of the sub-process is set to 0.
. The sub-process does not inherit the record lock of the parent process. Pending signals will not be inherited.
In Linux, fork is implemented by copy-on-write, that is, the child process and the parent process are different only from the page table and task structure at the beginning.