Forking with PHP
Process Control support in PHP does not work for web scripts, only for those started as standalone. If PHP is compiled with this options
./configure --prefix=/usr/local/php-5.3.10 --with-apxs2=/usr/sbin/apxs --with-mysql=/usr/local/mysql-5.1.41/ --with-pgsql=/usr/local/postgresql-8.4.1/ --with-xmlrpc --enable-pcntl
phpinfo()
shows that the configure command is
'./configure' '--prefix=/usr/local/php-5.3.10' '--with-apxs2=/usr/sbin/apxs' '--with-mysql=/usr/local/mysql-5.1.41/' '--with-pgsql=/usr/local/postgresql-8.4.1/' '--with-xmlrpc'
pcntl_fork()
like
<?php $pidNo = pcntl_fork(); if ($pidNo == -1) echo "error\n"; else if ($pidNo) { echo "parent id=" . getmypid() ."\n"; pcntl_wait($status); } else { echo "child id=" . getmypid() . "\n"; exit(0); } ?>
<?php $hello = isset($_REQUEST["hello"]) ? $_REQUEST["hello"] : "world"; echo "<p>hello=$hello</p>"; system("php fork.php"); ?>