Skip to content

Commit

Permalink
Fix warning "Use of uninitialized value in ...".
Browse files Browse the repository at this point in the history
If the list has only one item avoid sort subroutine.
  • Loading branch information
yangtse committed Nov 18, 2006
1 parent 74ddbd8 commit 2e17a97
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions tests/ftp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ sub pidfromfile {
if(open(PIDF, "<$pidfile")) {
my $pidline = <PIDF>;
close(PIDF);
chomp $pidline;
$pidline =~ s/^\s+//;
$pidline =~ s/\s+$//;
$pidline =~ s/^[+-]?0+//;
if($pidline =~ $pidpattern) {
$pid = $1;
if($pidline) {
chomp $pidline;
$pidline =~ s/^\s+//;
$pidline =~ s/\s+$//;
$pidline =~ s/^[+-]?0+//;
if($pidline =~ $pidpattern) {
$pid = $1;
}
}
}
}
Expand Down Expand Up @@ -150,6 +152,13 @@ sub signalpids {
if((not defined $signal) || (not defined $pids)) {
return;
}
if($pids !~ /\s+/) {
# avoid sorting if only one pid
if(checkalivepid($pids) > 0) {
kill($signal, $pids);
}
return;
}
my $prev = 0;
for(sort({$a <=> $b} split(" ", $pids))) {
if($_ =~ $pidpattern) {
Expand Down

0 comments on commit 2e17a97

Please sign in to comment.