mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-08 12:43:58 +00:00
allow input/output redirection in run_command
Those changes are needed by new vzdump code.
This commit is contained in:
parent
710d2994af
commit
1c50a24add
@ -177,11 +177,8 @@ sub run_command {
|
|||||||
my $pid;
|
my $pid;
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $reader = IO::File->new();
|
|
||||||
my $writer = IO::File->new();
|
|
||||||
my $error = IO::File->new();
|
|
||||||
|
|
||||||
my $input;
|
my $input;
|
||||||
|
my $output;
|
||||||
my $outfunc;
|
my $outfunc;
|
||||||
my $errfunc;
|
my $errfunc;
|
||||||
|
|
||||||
@ -198,6 +195,8 @@ sub run_command {
|
|||||||
};
|
};
|
||||||
} elsif ($p eq 'input') {
|
} elsif ($p eq 'input') {
|
||||||
$input = $param{$p};
|
$input = $param{$p};
|
||||||
|
} elsif ($p eq 'output') {
|
||||||
|
$output = $param{$p};
|
||||||
} elsif ($p eq 'outfunc') {
|
} elsif ($p eq 'outfunc') {
|
||||||
$outfunc = $param{$p};
|
$outfunc = $param{$p};
|
||||||
} elsif ($p eq 'errfunc') {
|
} elsif ($p eq 'errfunc') {
|
||||||
@ -207,6 +206,10 @@ sub run_command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $reader = $output && $output =~ m/^>&/ ? $output : IO::File->new();
|
||||||
|
my $writer = $input && $input =~ m/^<&/ ? $input : IO::File->new();
|
||||||
|
my $error = IO::File->new();
|
||||||
|
|
||||||
# try to avoid locale related issues/warnings
|
# try to avoid locale related issues/warnings
|
||||||
my $lang = $param{lang} || 'C';
|
my $lang = $param{lang} || 'C';
|
||||||
|
|
||||||
@ -312,6 +315,7 @@ sub run_command {
|
|||||||
} elsif (my $sig = ($? & 127)) {
|
} elsif (my $sig = ($? & 127)) {
|
||||||
die "got signal $sig\n";
|
die "got signal $sig\n";
|
||||||
} elsif (my $ec = ($? >> 8)) {
|
} elsif (my $ec = ($? >> 8)) {
|
||||||
|
if (!($ec == 24 && ($cmdstr =~ m|^(\S+/)?rsync\s|))) {
|
||||||
if ($errmsg && $laststderr) {
|
if ($errmsg && $laststderr) {
|
||||||
my $lerr = $laststderr;
|
my $lerr = $laststderr;
|
||||||
$laststderr = undef;
|
$laststderr = undef;
|
||||||
@ -319,6 +323,7 @@ sub run_command {
|
|||||||
}
|
}
|
||||||
die "exit code $ec\n";
|
die "exit code $ec\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alarm(0);
|
alarm(0);
|
||||||
};
|
};
|
||||||
@ -346,6 +351,8 @@ sub run_command {
|
|||||||
die "command '$cmdstr' failed: $err";
|
die "command '$cmdstr' failed: $err";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub split_list {
|
sub split_list {
|
||||||
|
Loading…
Reference in New Issue
Block a user