Matthew Tice wrote:
I've setup a simple (well, I copied it from someone else and modified it) to
monitor stale NFS mounts.  Some preliminary testing seemed to go okay but
this problem crept up on me this weekend.  The script is as follows:

#!/usr/bin/perl

use warnings;
use strict;

if (@ARGV < 1) {
        print "Usage:\n";
        print "$0 <file to check with absolute path>\n";
exit 1;
}

eval {
local $SIG{ALRM} = sub {die "alarm\n"};
alarm 2;
$test = `ls @ARGV[0]`;

If you had warnings enabled then perl would have told you to use $ARGV[0] instead of @ARGV[0].

Why are you starting an external shell to run the external ls command when all that ls does is stat the file and you can just do the same thing with Perl's built-in stat() function?


alarm 0;
};

if ($@) {
die unless $@ eq "alarm\n";
# Timed out - error
exit 1;
} else {
# Okay
exit 0;
}


However, on the machine that experienced the problem `ps aux` showed several
dead processes.  Shouldn't the alarm() function have exited?

When new_nfs_check.pl exits it takes its child, the shell, with it, but its grandchild, the ls command, is still left behind.



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to