run_command: allow to opt-out dying on non-zero exit code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-12-02 14:42:38 +01:00
parent ae71b49f69
commit 034835001d
1 changed files with 3 additions and 3 deletions

View File

@ -367,7 +367,7 @@ sub ve_exec {
} }
sub run_command { sub run_command {
my ($self, $cmd, $input, $getoutput) = @_; my ($self, $cmd, $input, $getoutput, $noerr) = @_;
my $reader = IO::File->new(); my $reader = IO::File->new();
my $writer = IO::File->new(); my $writer = IO::File->new();
@ -428,9 +428,9 @@ sub run_command {
waitpid ($pid, 0); waitpid ($pid, 0);
my $ec = ($? >> 8); my $ec = ($? >> 8);
die "command '$cmdstr' failed with exit code $ec\n" if $ec; die "command '$cmdstr' failed with exit code $ec\n" if $ec && !$noerr;
return $res; return wantarray ? ($res, $ec) : $res;
} }
sub start_container { sub start_container {