diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-14 23:57:05 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-14 23:57:05 -0700 |
commit | 49748fdfcf2aeeb6195563691bc38288d6d6f0d7 (patch) | |
tree | b7489594728b472b5f5c0386211f79423ec912b3 /perl5 | |
parent | 2d23e1708b42b17da7e333e7aee8f992854b0e9a (diff) | |
download | dotfiles-49748fdfcf2aeeb6195563691bc38288d6d6f0d7.tar.gz |
use 4-argument select() rather than SIGALRM for readability
Diffstat (limited to 'perl5')
-rw-r--r-- | perl5/Local/Interactive.pm | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/perl5/Local/Interactive.pm b/perl5/Local/Interactive.pm index 0cd6e912..fa66d18e 100644 --- a/perl5/Local/Interactive.pm +++ b/perl5/Local/Interactive.pm @@ -221,23 +221,17 @@ sub _sysptycap_tty { # SSH control socket is still alive (seems to happen when using # Debian's SSH jump host to SSH to salsa) while (kill 0, $pid) { - my ($chars, $nchars); - local $@; - eval { - local $SIG{ALRM} = sub { die "sysread timeout\n" }; - alarm 1; - $nchars = sysread $slave, $chars, 8192; - alarm 0; - }; - if (my $exception = $@) { - die $exception unless $exception eq "sysread timeout\n"; - # since it's stopped emitting output, see if child needs - # reaping + my $rin = ""; + vec($rin, fileno $slave, 1) = 1; + if (select $rin, undef, undef, 1) { + my $nchars = sysread $slave, my $chars, 8192; + last if defined $nchars and $nchars == 0; + print $chars; + $output .= $chars; + } else { + # since there was no new output, see if child needs reaping waitpid -1, &WNOHANG; } - last if defined $nchars and $nchars == 0; - print $chars; - $output .= $chars; } $slave->close; exit 2 if $interrupted; |