note 85687 added to function.pcntl-fork
| From: | csrster at gmail dot com | Date: | Fri, 12 Sep 2008 09:48:35 +0000 |
| Subject: | note 85687 added to function.pcntl-fork | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144359@lists.php.net to get a copy of this message | ||
Here's one way to execute a bunch of commands in an array, each in its own process
foreach ($cmds as $cmd) {
$pid=pcntl_fork();
if ($pid) {
exec($cmd);
break;
}
}
Don't forget the break statement!
I use this in a cli routine to rip a bunch of internet radio streams in parallel. This kind of
parallelism is natural here because the download rate for each stream is limited by the network, not
the cpu.
----
Server IP: 87.54.44.10
Probable Submitter: 130.225.25.18
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-fork.php
Edit -- https://master.php.net/note/edit/85687
Del: integrated -- https://master.php.net/note/delete/85687/integrated
Del: useless -- https://master.php.net/note/delete/85687/useless
Del: bad code -- https://master.php.net/note/delete/85687/bad+code
Del: spam -- https://master.php.net/note/delete/85687/spam
Del: non-english -- https://master.php.net/note/delete/85687/non-english
Del: in docs -- https://master.php.net/note/delete/85687/in+docs
Del: other reasons-- https://master.php.net/note/delete/85687
Reject -- https://master.php.net/note/reject/85687
Search -- https://master.php.net/manage/user-notes.php