以下例子,在主进程生成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)
以下例子,在主进程生成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)