From 873124695bbbdd85c144f2983ce38ab92d2e13fd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 27 Sep 2009 21:35:48 -0500 Subject: reread after getting a SIGWINCH --- lib/App/Termcast.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index ceb736c..b65a691 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -58,6 +58,14 @@ has bell_on_watcher => ( . " or disconnects", ); +has _got_winch => ( + traits => ['NoGetopt'], + is => 'rw', + isa => 'Bool', + default => 0, + init_arg => undef, +); + sub run { my $self = shift; my @argv = @{ $self->extra_argv }; @@ -77,12 +85,17 @@ sub run { vec($rin, $ptyfd, 1) = 1; vec($rin, $sockfd, 1) = 1; ReadMode 5; + local $SIG{WINCH} = sub { $self->_got_winch(1) }; while (1) { my $ready = select($rout = $rin, undef, undef, undef); if (vec($rout, fileno(STDIN), 1)) { my $buf; sysread STDIN, $buf, 4096; if (!defined $buf || length $buf == 0) { + if ($self->_got_winch) { + $self->_got_winch(0); + redo; + } warn "Error reading from stdin: $!" unless defined $buf; last; } @@ -91,6 +104,10 @@ sub run { if (vec($rout, $ptyfd, 1)) { my $buf = $pty->read(0); if (!defined $buf || length $buf == 0) { + if ($self->_got_winch) { + $self->_got_winch(0); + redo; + } warn "Error reading from pty: $!" unless defined $buf; last; } @@ -101,6 +118,10 @@ sub run { my $buf; $socket->recv($buf, 4096); if (!defined $buf || length $buf == 0) { + if ($self->_got_winch) { + $self->_got_winch(0); + redo; + } warn "Error reading from socket: $!" unless defined $buf; last; } -- cgit v1.2.3-54-g00ecf