]> git.proxmox.com Git - pve-common.git/commit - src/PVE/Tools.pm
run_command: return exit code and add noerr
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 30 Nov 2015 08:25:20 +0000 (09:25 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 30 Nov 2015 11:59:45 +0000 (12:59 +0100)
commit7e826928250804d0ca80aa6049f6353d1059bd53
tree85ea1ad7c62a1e7e85c7c827fc18b0ec9a19c83b
parent35e7d2398393ba7b60db3c168e78c29110c36d5f
run_command: return exit code and add noerr

Allow to return the exit code of the executed command.
And as we do not reach the return of the exit code if it was not 0,
a noerr parameter is also needed so we can suppress the 'command
failed' die in case of an exit code unequal to 0.

This is required as some programs return another value than 0 when
they succeed, For example `systemctl list-jobs` returns  a value
>= 0 on a successful execution, normally 1.
Without this patch a run_command call to `systemctl list-jobs` gets
marked as failed although it was successful.

This does not break current behaviour in any way as setting the
noerr parameter is required to return something other than 0 or
undef, which are equal in a boolean comparison.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Tools.pm