]> git.proxmox.com Git - pve-common.git/commitdiff
run_command: default exit code to -1
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 5 Apr 2017 09:35:53 +0000 (11:35 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 10 Apr 2017 12:50:13 +0000 (14:50 +0200)
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>
src/PVE/Tools.pm

index 2cd47333edf1dc043568ac0d5bcb0be782ca2828..1f0ec75784cbbc8313b0b315026f09aa4a4f1835 100644 (file)
@@ -341,7 +341,7 @@ sub run_command {
     my $timeout;
     my $oldtimeout;
     my $pid;
-    my $exitcode;
+    my $exitcode = -1;
 
     my $outfunc;
     my $errfunc;