summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-03 13:14:34 -0500
committerJesse Luehrs <doy@tozt.net>2010-11-03 13:16:33 -0500
commit95e0720dc0b6a2cf71b76f14c1943a0e3324a273 (patch)
treee5479af1e9cd7937809e62503864c5c9ceba0665 /lib
parentf605f3d9d1d7774c993176042961999e8e6c8754 (diff)
downloadapp-termcast-95e0720dc0b6a2cf71b76f14c1943a0e3324a273.tar.gz
app-termcast-95e0720dc0b6a2cf71b76f14c1943a0e3324a273.zip
actually make WINCH signal the subprocess properly0.09
Diffstat (limited to 'lib')
-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;