962148150 发表于 2017-5-18 10:56:07

perl多进程示例

  以下例子,在主进程生成3个子进程,然后再收割每个子进程,防止子进程成为僵尸进程
  


for(1..3){
$pid = fork;
if($pid == 0){//子进程
print $$,"\n";
sleep (3+int(rand(10)));
exit 0;
}
}
print "waitting --------\n";
print "process$p has exist\n" while(($p=wait)!=-1)
 
页: [1]
查看完整版本: perl多进程示例