- 论坛徽章:
- 0
|
还是不行, 有问题
#!/usr/bin/perl -w
use strict;
use warnings;
use POSIX;
$SIG{CHLD} = 'IGNORE';
my $isFinished = 0;
sub fun {
$isFinished = 1;
print "Im $$ too ,the value has been changed to $isFinished..\n";
}
defined(my $child = fork()) or die "cant fork";
if($child == 0) {
sleep 3;
print "Im the child my pid $, I found the value still is $isFinished \n";
exit ;
}
print "I m $$ running the child supposed sleeping . the value is $isFinished\n";
fun();
exit;
|
是不是因为sleep的原因 ?
那要如何判断段代码执行是否超时呢?
希望实现的是判断一个进程 超时后重启 Linux下 |
|