# the open files because they are owned by another user.
# On modern (Debian) systems, condition a) is not met.
my @lsof_args = (LSOF_BIN, "-Fn",
- map { "$directory/$_" } keys %possible);
- ftp_syslog('debug', "DEBUG: "
- ."lsof command line: " . join(' ',@lsof_args))
+ map { File::Spec->catfile($directory, $_) } keys %possible);
+ ftp_syslog('debug', "DEBUG: lsof command line: " . join(' ',@lsof_args))
if DEBUG;
- my $pid = open (LSOF, "-|");
- if ($pid) { # parent
- while (defined (my $line = <LSOF>)) {
- ftp_syslog('debug', "DEBUG: " . "lsof output: $line")
- if DEBUG;
- # only look at the name lines.
- next unless $line =~ /^n${directory}\/(.+)$/;
- ftp_syslog('debug', "DEBUG: "
- ."upload in progress for $1, ignoring during this run")
- if DEBUG;
- delete ($possible{$1})
- or ftp_warn("WARNING: lsof found unrequested but open $1?!");
- }
- close (LSOF);
- } else { # child
- exec (@lsof_args)
- or ftp_die("FATAL: cannot exec lsof: $!");
+ open LSOF, '-|', @lsof_args
+ or ftp_die("FATAL: cannot spawn lsof: $!");;
+ while (<LSOF>) {
+ ftp_syslog('debug', "DEBUG: lsof output: $_") if DEBUG;
+ # only look at the name lines
+ next unless /^n${directory}\/(.+)$/;
+ ftp_syslog('debug', "DEBUG: "
+ ."upload in progress for $1, ignoring during this run")
+ if DEBUG;
+ delete ($possible{$1})
+ or ftp_warn("WARNING: lsof found unrequested but open $1?!");
}
+ close (LSOF);
my @ret;