Take the rest of these two days and release the basic C linux API and standard library content ~~, As a record, it is also for your reference. Please submit comments more.
The Create process API is defined in unistd. h.
Function prototype:
Pid_t fork (void );
The child process returns 0, and the parent process returns the child process pid.
If the parent process does not process the exit status of the child process, the child process becomes Z process.
Avoid Z process:
1. Use pid_t waitpid (pid_t, int *, int); to block and wait for the sub-process to exit.
2. The parent process uses singal for asynchronous processing. When the child process ends, SIGCHLD signal is sent to the parent process. The parent process receives SIGCHLD and then calls waitpid ().
For the definition and operation of signals, see signal. h.
<To be continue...>
From leonzhang