[pve-devel] [PATCH common] run_command: default exit code to -1

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Apr 5 11:35:53 CEST 2017


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 at proxmox.com>
---
 src/PVE/Tools.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 2cd4733..1f0ec75 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -341,7 +341,7 @@ sub run_command {
     my $timeout;
     my $oldtimeout;
     my $pid;
-    my $exitcode;
+    my $exitcode = -1;
 
     my $outfunc;
     my $errfunc;
-- 
2.11.0





More information about the pve-devel mailing list