1. A child process is a copy of the parent process. It obtains the data space/Heap/stack of the parent process, and the parent and child processes share the code segment. the child process starts to run after fork. The returned value = 0 indicates the child process, because the child process can obtain the ID of the parent process through the function, but the parent process cannot know the ID of the child process.
2. to improve the submission efficiency, fork does not immediately copy the space of the parent process, but uses the cow technology, that is, when the parent process or child process needs to modify the data segment/Heap/stack, the replication operation is performed and the modified region is copied.
3. The file descriptor copied by the sub-process from the parent process. It points to the same file object as the parent process, that is, the file offset/flag is shared.
4. the difference between without-lpthread and locking blocking of mutex is caused by the selection of strong and weak symbols and dynamic link libraries during the link, for details, refer to the Problem description and solution: Click the open link.
Process encapsulation of Lilin apue