use POSIX;
foreach my $id(sort keys %serv)
{
my $pid=fork();
if($pid==0)
{
alarm(10);
qq#$cmd#;
alarm(0);
exit;
}
else
{
$chd_pid{$pid}=0
}
}
#等待回收子进程
while (scalar (keys %chd_pid))
{
my $pid = 0;
$pid=waitpid(-1, NULL);
if (exists $chd_pid{$pid})
{
print "pid = $pid \n";
delete $chd_pid{$pid};
}
}
阅读(636) | 评论(0) | 转发(0) |