Re: Re: process creation

From: Date: Sat, 24 Jan 2009 09:33:08 +0000
Subject: Re: Re: process creation
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-287062@lists.php.net to get a copy of this message
Török Alpár wrote: > as i said it's hate here, and i might be wrong but consider the > following : > > for($icount=0;$icount<11;$icount++) > { > $iPid = pcntl_fork(); > $iChildrenCount = 0; > if ($iPid == 0) > { > // child > echo ("child $icount\n"); > } > else > { > // parrent > } > } > > this is essential what you do in your example? If so, this code does > not start 10 children. It starts more. Thats right - with the code above, each new child will continue creating more processes. To get exactly 10 children running the same code: if ($iPid == 0) { // child echo ("child $icount\n"); // do childish stuff // then exit exit; } /Per Jessen, Zürich

« previous php.general (#287062) next »