From 95e0720dc0b6a2cf71b76f14c1943a0e3324a273 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 3 Nov 2010 13:14:34 -0500 Subject: actually make WINCH signal the subprocess properly --- lib/App/Termcast.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/App/Termcast.pm b/lib/App/Termcast.pm index 6fd6b4d..48a8734 100644 --- a/lib/App/Termcast.pm +++ b/lib/App/Termcast.pm @@ -249,12 +249,22 @@ sub run { $self->pty->spawn(@cmd) || die "Couldn't spawn @cmd: $!"; - local $SIG{WINCH} = sub { $self->_got_winch(1) }; + local $SIG{WINCH} = sub { + $self->_got_winch(1); + $self->pty->slave->clone_winsize_from(\*STDIN); + $self->pty->kill('WINCH', 1); + }; + while (1) { my ($rin, $win, $ein) = $self->_build_select_args; my ($rout, $wout, $eout); my $select_res = select($rout = $rin, undef, $eout = $ein, undef); - redo if $select_res == -1 && ($!{EAGAIN} || $!{EINTR}); + my $again = $!{EAGAIN} || $!{EINTR}; + + if (($select_res == -1 && $again) || $self->_got_winch) { + $self->_got_winch(0); + redo; + } if ($self->_socket_ready($eout)) { $self->clear_socket; @@ -264,10 +274,6 @@ sub run { my $buf; sysread STDIN, $buf, 4096; if (!defined $buf || length $buf == 0) { - if ($self->_got_winch) { - $self->_got_winch(0); - redo; - } Carp::croak("Error reading from stdin: $!") unless defined $buf; last; -- cgit v1.2.3-54-g00ecf