Chad Kellerman wrote:
> david,
>
> actually, without the while loop every user in the array gets forked
> at one time. 500+ forks. I put the while loop in and it does one at a
> time..
>
maybe i am missing something but how is this:
> foreach my $usr (@users) {
> my $UsrPid;
> unless ($UsrPid = fork) {
> while fork {
> do stuff
> exit 0;
> }
> exit 0;
> }
> waitpid($UsrPid,0);
> }
different than:
foreach my $user (@users){
my $UserPid = fork;
if($UserPid){
waitpid($UserPid,0);
}else{
#-- do stuff;
exit;
}
}
if @users has 500 elements, the fisrt version does 1000 forks.
the second version does only 500 forks
at last, only the main process's parent is living.
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]