note 62099 added to function.pcntl-wait

From: Date: Mon, 20 Feb 2006 00:39:08 +0000
Subject: note 62099 added to function.pcntl-wait
Groups: php.notes 
Request: Send a blank email to php-notes+get-104044@lists.php.net to get a copy of this message
This a simple multi process application where you can choose the maximun process that can run at the same time. This is useful when you need to limit the fork of process. When the MAXPROCESS is reached the program wait on pcntl_wait() <? DEFINE(MAXPROCESS,25); for ($i=0;$i<100;$i++){ $pid = pcntl_fork(); if ($pid == -1) { die("could not fork"); } elseif ($pid) { echo "I'm the Parent $i\n"; $execute++; if ($execute>=MAXPROCESS){ pcntl_wait($status); $execute--; } } else { echo "I am the child, $i pid = $pid \n"; sleep(rand(1,3)); echo "Bye Bye from $i\n"; exit; } } ?> ---- Server IP: 80.241.173.254 Probable Submitter: 84.222.181.251 ---- Manual Page -- http://www.php.net/manual/en/function.pcntl-wait.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+62099 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62099&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+62099&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104044) next »