example:
my $maxchild=10;
for($i=0;$i<=$maxchild-1;$i++)
{
my $child=fork();
if($child) { # child >; 0, so we're the parent
warn "launching child $child\n";
}else{
do_child($i); # child handles
exit 0; # child is done
}
}
exit;
sub do_child
{
my $child_number=shift(@_);
print("child ,$child_number \n");
}
阅读(1909) | 评论(1) | 转发(0) |