If the list has only one item avoid sort subroutine.
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;
+ }
}
}
}
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) {