aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2006-11-18 04:05:42 +0000
committerYang Tse <yangsita@gmail.com>2006-11-18 04:05:42 +0000
commit2e17a9747470be98b3d7e2cef3a918bd5249f279 (patch)
treed14df13213a52a7169fa1ec1b6541600addc54a4
parent74ddbd8a3ba5d9957de6f0ba32e8349a3be424f6 (diff)
Fix warning "Use of uninitialized value in ...".
If the list has only one item avoid sort subroutine.
-rw-r--r--tests/ftp.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/ftp.pm b/tests/ftp.pm
index 32c6779e3..663744545 100644
--- a/tests/ftp.pm
+++ b/tests/ftp.pm
@@ -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;
+ }
}
}
}
@@ -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) {