Created
February 10, 2012 11:22
-
-
Save davel/1788840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $pid; | |
my $timed_out; | |
local $SIG{ALRM} = sub { | |
$timed_out = 1; | |
warn "all went wrong"; | |
kill(9, $pid) if $pid; | |
}; | |
alarm(30); | |
$pid = fork(); | |
die "yikes: $!" unless defined $pid; | |
unless ($pid) { | |
open(my $fh, "<", $filename) or die $!; | |
exit 0; | |
} | |
waitpid $pid, 0; | |
alarm(0); | |
if ($timed_out or $?) { | |
... what we do when we've lost NFS | |
} | |
else { | |
... nfs good | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my $filename = $CONFIG->{healthcheck_base};
my $timed_out;
local $SIG{ALRM} = sub {
$timed_out = 1;if
warn "all went wrong"
};
alarm(6);
my $pid = fork();
die "yikes: $!" unless defined $pid;
unless ($pid) {$filename) or die $ !;
open(my $fh, "<",
}
try {
waitpid $pid, 0;
}
catch {
warn $_;
};
alarm(0);
if ($timed_out or $ ?) {
$return=1;
}
else {
$return = 0;
}
ok( $return, 'NFS mount ok' );