while(1) { # timestamp the check $ffail=0; open (HC,"> $heartcheckfile") or $ffail=1; if ($ffail == 0) { print HC "$mypid\n"; close (HC); } # check for heartbeat $res = check_filemod($margin+$interval,1,$heartfile); if ($res == 0) { # PH healthy sleep ($interval*60); # otherwise, nothing to do but wait for next check } # exception if $res !=0 omiitted as not executed @lines = `tasklist /FI \"IMAGENAME eq wperl.exe\"`; my $found=0; foreach $line (@lines) { @words = split " ",$line; if (($#words > 0) && ($words[0] =~ "wperl") && ($words[1] ne $mypid)) { $found=1; } } # exception if found=0 omitted as not typically executed }