run_command: default exit code to -1

When the child process running the command got  an signal or failed
to execute exitcode was still undefined as we extract it just only
after the signal/failed to execute check.
This led to:
 > Use of uninitialized value in numeric ne (!=) at
 > /usr/share/perl5/PVE/API2/Qemu.pm line 1433.
errors if we used run_commands `noerr` param and checked for the
commands exit code.

So just default the exit code to -1 for such cases.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2017-04-05 11:35:53 +02:00 committed by Fabian Grünbichler
parent 86b8423739
commit 38d9aa1247

View File

@ -341,7 +341,7 @@ sub run_command {
my $timeout; my $timeout;
my $oldtimeout; my $oldtimeout;
my $pid; my $pid;
my $exitcode; my $exitcode = -1;
my $outfunc; my $outfunc;
my $errfunc; my $errfunc;