Home > Article > Backend Development > Example of using pcntl_fork to implement PHP multi-process
Explanation: int pcntl_fork ( void ) The pcntl_fork() function creates a child process that is different from its parent process only in PID (process ID) and PPID (parent process ID). On success, the PID of the generated child process is returned in the parent process execution thread, and 0 is returned in the child process execution thread. On failure, -1 is returned in the parent process context, the child process is not created, and a PHP error is raised. int pcntl_wait ( int &$status [, int $options = 0 ] ) pcntl_wait — Wait for or return the child process status of fork void pcntl_exec ( string $path [, array $args [, array $envs ]] ) pcntl_exec — Execute the specified program in the current process space Example:
|