note 110790 added to function.pcntl-fork
| From: | manishpatel2280 at gmail dot com | Date: | Sat, 08 Dec 2012 06:41:22 +0000 |
| Subject: | note 110790 added to function.pcntl-fork | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192395@lists.php.net to get a copy of this message | ||
Its been easy to fork process with pcntl_fork.. but how can we control or process further once all
child processes gets completed.. here is the way we can do that...
for ($i = 1; $i <= 5; ++$i) {
$pid = pcntl_fork();
if (!$pid) {
sleep(1);
print "In child $i\n";
exit($i);
}
}
while (pcntl_waitpid(0, $status) != -1) {
$status = pcntl_wexitstatus($status);
echo "Child $status completed\n";
}
----
Server IP: 59.162.86.123
Probable Submitter: 110.226.169.25
----
Manual Page -- http://php.net/manual/en/function.pcntl-fork.php
Edit -- https://master.php.net/note/edit/110790
Del: integrated -- https://master.php.net/note/delete/110790/integrated
Del: useless -- https://master.php.net/note/delete/110790/useless
Del: bad code -- https://master.php.net/note/delete/110790/bad+code
Del: spam -- https://master.php.net/note/delete/110790/spam
Del: non-english -- https://master.php.net/note/delete/110790/non-english
Del: in docs -- https://master.php.net/note/delete/110790/in+docs
Del: other reasons-- https://master.php.net/note/delete/110790
Reject -- https://master.php.net/note/reject/110790
Search -- https://master.php.net/manage/user-notes.php