[pve-devel] applied: [PATCH pve-client v2] Poll the size of the terminal and resize if needed

Dietmar Maurer dietmar at proxmox.com
Fri Jun 8 06:41:39 CEST 2018


applied. Works great!

> On June 7, 2018 at 2:29 PM René Jochum <r.jochum at proxmox.com> wrote:
> 
> 
> Signed-off-by: René Jochum <r.jochum at proxmox.com>
> ---
> This adds the the WINCH signal handling instead of polling the window size
> every x seconds.
> 
> Thanks to Wolfgang Bumiller :)
> 
>  PVE/APIClient/Commands/lxc.pm | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
> index e0d21ae..f0c85f7 100644
> --- a/PVE/APIClient/Commands/lxc.pm
> +++ b/PVE/APIClient/Commands/lxc.pm
> @@ -262,8 +262,24 @@ __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)) {
> +		    $check_terminal_size->() if $winch_received;
> +
>  		    foreach my $fh (@ready) {
>  
>  			if ($fh == $web_socket) {
> @@ -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
>  	    }
> -- 
> 2.11.0
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



More information about the pve-devel mailing list