summaryrefslogtreecommitdiffstats
path: root/lib/App/Termcast.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/Termcast.pm')
-rw-r--r--lib/App/Termcast.pm18
1 files changed, 12 insertions, 6 deletions
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;