You want to watch PCNTL . Keep in mind that it is designed for CGI-mod, but it can be used for apache.
Usage example:
<?php // Create the MySQL connection $db = mysql_connect($server, $username, $password); $pid = pcntl_fork(); if ( $pid == -1 ) { // Fork failed exit(1); } else if ( $pid ) { // We are the parent // Can no longer use $db because it will be closed by the child // Instead, make a new MySQL connection for ourselves to work with $db = mysql_connect($server, $username, $password, true); } else { // We are the child // Do something with the inherited connection here // It will get closed upon exit exit(0); ?>
source share