Re: Forking PHP Processes on Unix (PHP4)

From: Date: Mon, 04 Aug 2003 02:38:54 +0000
Subject: Re: Forking PHP Processes on Unix (PHP4)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-158103@lists.php.net to get a copy of this message
PHP can fork on Unix, just not from a web environment. So you need to execute the command from the command line or maybe an exec. Take a look at: http://www.php.net/manual/en/ref.pcntl.php Jason Damien G wrote:
Hi Readers, Heres what i'm trying to achieve: A script, that uses multiple fsockopen()'s and simltaniously get feedback from each socket from fget()s. Now, since using a single fget() needs to be in a loop then it's not possible to have more than one loop going at the same time. I was thinking of using a break command, then getting feedback from the other loops, and breaking each of them inside a encapsulating loop - however, this is VERY ineffective. What I thought about doing was just using the same script launched multiple times, so it has diffrent proccesses running and therefore would be able to complete the task of having multiple loops running at the same time on the same system. The problem I've found out is that on Unix (the desired OS breed), PHP can't be forked - so using a start.php script to execute multiple system() calls wouldn't work becuase PHP waits till the system() function has finished before carrying on with the rest of start.php. i.e. The following won't work: PHP:------------------------------------------------------------------------ ------ for ($i = 0; $i < 5; $i++) { system ("/path/to/php /path/to/script.php &"); } ---------------------------------------------------------------------------- -- Basically, i'm asking if anyone has a work around, or alternativley a answer to my problem? I'd much appritiate it, or any help you can contribute. Thanks in advance, or for atleast reading to this point -Damien


« previous php.general (#158103) next »