- 04
- Mon
PHP – Basic Fork Example
<? print "Starting main program\n"; $childs = array(); for ( $count = 1; $count <= 10; $count++) { $pid = pcntl_fork(); if ( $pid == -1 ) { // Fork failed echo "Fork failed\n"; exit(1); } else if ( $pid ) { # parent #print "pid is $pid, parent $$\n"; array_push($childs, $pid); } […]