Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


sleemanj

1474 posts

Uber Geek


#83431 16-May-2011 22:00
Send private message

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).

 




---
James Sleeman
I sell lots of stuff for electronic enthusiasts...


Create new topic
sleemanj

1474 posts

Uber Geek


  #469923 17-May-2011 00:54
Send private message

I ended up having to have the child write it's exit status to a file then send itself SIGKILL, parent waits to reap the child and reads the exit status from the appropriate file.

Not pretty really, but I guess it works well enough :-/




---
James Sleeman
I sell lots of stuff for electronic enthusiasts...


Create new topic





News and reviews »

Year in Search: What Kiwis Searched for in 2023
Posted 12-Dec-2023 08:18


New Air Traffic Management Platform and Resilient Buildings a Milestone for Airways
Posted 6-Dec-2023 05:00


Logitech G Launches New Flagship Console Wireless Gaming Headset Astro A50 X
Posted 5-Dec-2023 21:00


NordVPN Helps Users Protect Themselves From Vulnerable Apps
Posted 5-Dec-2023 14:27


First-of-its-Kind Flight Trials Integrate Uncrewed Aircraft Into Controlled Airspace
Posted 5-Dec-2023 13:59


Prodigi Technology Services Announces Strategic Acquisition of Conex
Posted 4-Dec-2023 09:33


Samsung Announces Galaxy AI
Posted 28-Nov-2023 14:48


Epson Launches EH-LS650 Ultra Short Throw Smart Streaming Laser Projector
Posted 28-Nov-2023 14:38


Fitbit Charge 6 Review
Posted 27-Nov-2023 16:21


Cisco Launches New Research Highlighting Gap in Preparedness for AI
Posted 23-Nov-2023 15:50


Seagate Takes Block Storage System to New Heights Reaching 2.5 PB
Posted 23-Nov-2023 15:45


Seagate Nytro 4350 NVMe SSD Delivers Consistent Application Performance and High QoS to Data Centers
Posted 23-Nov-2023 15:38


Amazon Fire TV Stick 4k Max (2nd Generation) Review
Posted 14-Nov-2023 16:17


Over half of New Zealand adults surveyed concerned about AI shopping scams
Posted 3-Nov-2023 10:42


Super Mario Bros. Wonder Launches on Nintendo Switch
Posted 24-Oct-2023 10:56



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.