[pve-devel] [PATCH pve-client 4/7] lxc enter: cleanup filehandle usage
Dietmar Maurer
dietmar at proxmox.com
Fri Jun 8 11:25:54 CEST 2018
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/APIClient/Commands/lxc.pm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
index 620e4b1..4360183 100644
--- a/PVE/APIClient/Commands/lxc.pm
+++ b/PVE/APIClient/Commands/lxc.pm
@@ -3,6 +3,7 @@ package PVE::APIClient::Commands::lxc;
use strict;
use warnings;
use Errno qw(EINTR EAGAIN);
+use Fcntl;
use JSON;
use URI::Escape;
use IO::Select;
@@ -260,10 +261,10 @@ __PACKAGE__->register_method ({
STDIN->blocking(0);
$web_socket->blocking(1);
$read_select->add($web_socket);
- my $input_fh = fileno(STDIN);
+ my $input_fh = \*STDIN;
$read_select->add($input_fh);
- my $output_fh = fileno(STDOUT);
+ my $output_fh = \*STDOUT;
my $ctrl_a_pressed_before = 0;
@@ -304,7 +305,7 @@ __PACKAGE__->register_method ({
foreach my $fh (@$writable) {
if ($fh == $output_fh) {
- $drain_buffer->(\*STDOUT, \$output_buffer);
+ $drain_buffer->($output_fh, \$output_buffer);
$read_select->add($web_socket) if length($output_buffer) <= $max_buffer_len;
} elsif ($fh == $web_socket) {
$drain_buffer->($web_socket, \$websock_buffer);
@@ -336,7 +337,7 @@ __PACKAGE__->register_method ({
} elsif ($fh == $input_fh) {
# Read from STDIN
- my $nr = read(\*STDIN, my $buff, 4096);
+ my $nr = sysread($input_fh, my $buff, 4096);
return if !$nr; # EOF or error
my $char = ord($buff);
--
2.11.0
More information about the pve-devel
mailing list