I had a similar problem.
Direct forking is not possible, so I did a workaround to do this.
You write a script for the normal User-Output. Within this code you initiate another request to your webserver, which starts the worker-script. After that the worker script runs in Background.
Works fine for me.
Code looks like this:
$service_port = getservbyname ('www', 'tcp');
$address = $GLOBALS["SERVER_ADDR"];
$socket = socket (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
echo "socket() failed: reason: " .
strerror ($socket) . "\n";
}
/ Establish connection /
$result = connect ($socket, $address, $service_port);
if ($result < 0) {
echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n";
}
/ Send Request to server /
$in = "GET /your_directory/workerscript.php4?yourArgs=blabla\r\n\r\n";
write ($socket, $in, strlen ($in));
/ Close Socket /
close($socket);
Be careful with execution time limits in your worker script. There are two limits: execution time limit from php and request time limit apache (if you use it).
You have to enable ignore_user_abort(true) in your worker-script, because it would die immediately after your first script closes the connection.
Stephan