1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

Fix warning "Use of uninitialized value in ...".

If the list has only one item avoid sort subroutine.
This commit is contained in:
Yang Tse 2006-11-18 04:05:42 +00:00
parent 74ddbd8a3b
commit 2e17a97474

View File

@ -55,12 +55,14 @@ sub pidfromfile {
if(open(PIDF, "<$pidfile")) { if(open(PIDF, "<$pidfile")) {
my $pidline = <PIDF>; my $pidline = <PIDF>;
close(PIDF); close(PIDF);
chomp $pidline; if($pidline) {
$pidline =~ s/^\s+//; chomp $pidline;
$pidline =~ s/\s+$//; $pidline =~ s/^\s+//;
$pidline =~ s/^[+-]?0+//; $pidline =~ s/\s+$//;
if($pidline =~ $pidpattern) { $pidline =~ s/^[+-]?0+//;
$pid = $1; if($pidline =~ $pidpattern) {
$pid = $1;
}
} }
} }
} }
@ -150,6 +152,13 @@ sub signalpids {
if((not defined $signal) || (not defined $pids)) { if((not defined $signal) || (not defined $pids)) {
return; return;
} }
if($pids !~ /\s+/) {
# avoid sorting if only one pid
if(checkalivepid($pids) > 0) {
kill($signal, $pids);
}
return;
}
my $prev = 0; my $prev = 0;
for(sort({$a <=> $b} split(" ", $pids))) { for(sort({$a <=> $b} split(" ", $pids))) {
if($_ =~ $pidpattern) { if($_ =~ $pidpattern) {