For reasons which are unimportant, we have something like the following code snippet...
foreach($Threads as $Thread)
{
$childpid = pcntl_fork();
if($childpid == 0)
{
echo "!! Forked\n"; $this->flush();
$rc = $this->ftp_puller_thread($Thread);
exit($rc);
}
elseif($childpid > 0)
{
// We are the parent, spawn another (or fall through to wait on the exit statuses)
$ThreadsRunning[$childpid] = true;
sleep(rand(5,20)); // Don't hammer
}
}
while(count($ThreadsRunning))
{
$childpid = pcntl_wait($status);
if($childpid > 0)
{
unset($ThreadsRunning[$childpid]);
if(pcntl_wexitstatus($status) > 0) $Result = FALSE;
}
}
which works, except, when the child exits, it seems to close out the browser connection, the parent never gets to finish doing what it's doing (nor I expect do other children). I'm GUESSING that php in it's cleanup etc is telling mod_fastcgi that it's done, when in fact, it's not, only a child is done. Has anybody got any clue on any way I might be able to STOP php from doing that, while still retaining the exit status (that is, I don't want to do a sigint 9 or something else ugly like that).