<?PHP//use Pcntl_fork () to generate child processes when the program needs to fork, and then perform the tasks simultaneously in multiple threads $pid=pcntl_fork (); if($pdi< 0) Exit(' Fork error! '); if($pid) { //if the PID is greater than 0, then it is the parent process,//This side let the parent process directly return data to the client, to achieve the effect of the fact #dothing}Else { //child processes, allowing the child process to perform complex business logic. Let it sleep 100s Sleep(100); } /*above this way, has been able to implement multi-threaded simultaneous processing, but, the child process has been running, then 1, the process has been there, the Linux system will be consumed by the death of 2, the client page has been in the Refresh page, customer experience poor
*/ //solve the problem: the//Sub-process executes the code logic and exits its die () or exit () directly, freeing up the resources it occupies. But there is a problem, producing n multiple defunct (zombie process)//Then how to eliminate the zombie process//1, the parent class uses pcntl_wait () to wait for the child process to end and recycle it. 2, defined at the beginning of the page, allowing the system to automatically recycle the zombie process (note: After the child process is finished, you must die or exit or exec (' kill-9 '. Posix_getpid ()))Pcntl_signal (SIGCLD,sig_ign); Pcntl_signal (SIGCHLD, sig_ign);