Commit 2e17a974 authored by Yang Tse's avatar Yang Tse
Browse files

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

If the list has only one item avoid sort subroutine.
parent 74ddbd8a
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ sub pidfromfile {
        if(open(PIDF, "<$pidfile")) {
            my $pidline = <PIDF>;
            close(PIDF);
            if($pidline) {
                chomp $pidline;
                $pidline =~ s/^\s+//;
                $pidline =~ s/\s+$//;
@@ -64,6 +65,7 @@ sub pidfromfile {
                }
            }
        }
    }
    return $pid;
}

@@ -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) {