mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-15 04:02:49 +00:00
fix stdin/sdout redirection
This commit is contained in:
parent
b749019d13
commit
f38995ab14
@ -225,6 +225,15 @@ sub run_command {
|
|||||||
local $ENV{LVM_SUPPRESS_FD_WARNINGS} = "1";
|
local $ENV{LVM_SUPPRESS_FD_WARNINGS} = "1";
|
||||||
|
|
||||||
$pid = open3($writer, $reader, $error, @$cmd) || die $!;
|
$pid = open3($writer, $reader, $error, @$cmd) || die $!;
|
||||||
|
|
||||||
|
# if we pipe fron STDIN, open3 closes STDIN, so we we
|
||||||
|
# a perl warning "Filehandle STDIN reopened as GENXYZ .. "
|
||||||
|
# as soon as we open a new file.
|
||||||
|
# to avoid that we open /dev/null
|
||||||
|
if (!ref($writer) && !defined(fileno(STDIN))) {
|
||||||
|
POSIX::close(0);
|
||||||
|
open(STDIN, "</dev/null");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
@ -241,11 +250,13 @@ sub run_command {
|
|||||||
local $SIG{ALRM} = sub { die "got timeout\n"; } if $timeout;
|
local $SIG{ALRM} = sub { die "got timeout\n"; } if $timeout;
|
||||||
$oldtimeout = alarm($timeout) if $timeout;
|
$oldtimeout = alarm($timeout) if $timeout;
|
||||||
|
|
||||||
|
if (ref($writer)) {
|
||||||
print $writer $input if defined $input;
|
print $writer $input if defined $input;
|
||||||
close $writer;
|
close $writer;
|
||||||
|
}
|
||||||
|
|
||||||
my $select = new IO::Select;
|
my $select = new IO::Select;
|
||||||
$select->add($reader);
|
$select->add($reader) if ref($reader);
|
||||||
$select->add($error);
|
$select->add($error);
|
||||||
|
|
||||||
my $outlog = '';
|
my $outlog = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user