PHP\'s pcntl_fork function is supposed to fork a process just as the standard fork function in C.
But I was wondering if this function really forks the process or if it
pcntl_fork probably works as you think it would : it forks the current process, the same way the C function fork does :
The
pcntl_fork()
function creates a child process that differs from the parent process only in its PID and PPID.
Please see your system'sfork(2)
man page for specific details as to how fork works on your system.
But, quoting the Introduction of the Process Control section of the manual :
Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination.
Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.
So, you should not actually use that function from a PHP script executed via Apache : it should only be used when your PHP script is executed from the command-line.
And, before starting to use that function, don't forget that :
Note: This extension is not available on Windows platforms.