Skip to content

Commit

Permalink
Add timeout for lsof
Browse files Browse the repository at this point in the history
If we have dead nfs mounts, lsof might hangover. Limit a timeout and
return an error message if lsof fails.
  • Loading branch information
donald committed Mar 10, 2018
1 parent e0c2bb4 commit 2e711ed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -1204,12 +1204,16 @@ sub clp_rx_LSOF {
defined $pid or die "$!\n";
unless ($pid) {
$socket->blocking(1);
open P,'lsof|' or die "$!\n";
open P,'timeout -k 12s 10s lsof|' or die "$!\n";
while (<P>) {
next if defined $pattern && index($_,$pattern)<0;
$socket->send(pack('n',length($_)).$_,0);
}
close P;
if ($?) {
$_=sprintf("** lsof timout/error on %s\n",$my_hostname);
$socket->send(pack('n',length($_)).$_,0);
}
close $socket;
exit;
}
Expand Down

0 comments on commit 2e711ed

Please sign in to comment.