X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FCommands%2Flxc.pm;h=c092028a722ed7d4959dff6aea7a670ec10443d4;hp=e0d21ae935d1d2a34dfa53ecacaa8096b2cbd276;hb=e4c016351a2e807c569c4706f778298529b16761;hpb=678b245c5483c4928de08f2903b3a233b2f5ddfa diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm index e0d21ae..c092028 100644 --- a/PVE/APIClient/Commands/lxc.pm +++ b/PVE/APIClient/Commands/lxc.pm @@ -262,9 +262,25 @@ __PACKAGE__->register_method ({ my $ctrl_a_pressed_before = 0; + my $winch_received = 0; + $SIG{WINCH} = sub { $winch_received = 1; }; + + my $check_terminal_size = sub { + my ($ncols, $nrows) = PVE::PTY::tcgetsize(*STDIN); + if ($ncols != $columns or $nrows != $rows) { + $columns = $ncols; + $rows = $nrows; + $frame = $create_websockt_frame->("1:$columns:$rows:"); + $full_write->($web_socket, $frame); + } + $winch_received = 0; + }; + while (1) { - while(my @ready = $select->can_read(3)) { - foreach my $fh (@ready) { + while(my ($readable) = IO::Select->select($select, undef, undef, 3)) { + $check_terminal_size->() if $winch_received; + + foreach my $fh (@$readable) { if ($fh == $web_socket) { # Read from WebSocket @@ -300,6 +316,8 @@ __PACKAGE__->register_method ({ } } } + $check_terminal_size->() if $winch_received; + # got timeout $full_write->($web_socket, $create_websockt_frame->("2")); # ping server to keep connection alive }