Process-related functions
pid_t Fork ();
header file :unistd.h,sys/types.h
role : Establish a new process (child process) that shares the code snippet with the original process (the parent process) and has a copy of the parent process's other resources (data, stacks, and so on). (Because all States of the parent process are inherited, the child process runs down from the Fork ). (Note: The child process inherits all the data from the parent process, but when executed, the data is separate and no longer affects each other.) The fork function copies the data segments and stacks, just "logically" on, not "physical", that is, the physical space on the two process data and stack segments are still shared, when there is a process to write a certain data, then the data between two processes is different, The system separates the "pages" of the difference from the physical. The overhead of the system can be minimized. )
parameters : None
return value : Thepid_t type, which is an alias of Int. If called successfully, returns two values. The fork () function returns the process ID of the child process in the parent process and returns 0 in the child process . This feature can be used to enable a process to identify itself as a parent or child process. If an error occurs, a negative value is returned.
Semaphore correlation function
Complex PC problems under Linux-multi-process programming/semaphore communication/shared storage area