I wrote a simple function that can "spawn" another thread within the webserver by making async http request. The page that is being spawned can call ignore_user_abort() and do whatever it wants in the background...
<?php
function http_spawn($page)
{
$basepath=ereg_replace('[^/]*$', '', $_SERVER['PHP_SELF']);
$cbSock=fsockopen('localhost', $_SERVER['SERVER_PORT'], $errno, $errstr, 5);
if ($cbSock)
{
fwrite($cbSock, "GET {$basepath}{$page} HTTP/1.0\r\n"
."Host: {$_SERVER['HTTP_HOST']}\r\n\r\n");
}
}
?>
Example:
<?php
if ($search_initialized)
http_spawn("ftindex.php");
?>