summaryrefslogtreecommitdiff
path: root/perl5
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-04-14 23:57:05 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-04-14 23:57:05 -0700
commit49748fdfcf2aeeb6195563691bc38288d6d6f0d7 (patch)
treeb7489594728b472b5f5c0386211f79423ec912b3 /perl5
parent2d23e1708b42b17da7e333e7aee8f992854b0e9a (diff)
downloaddotfiles-49748fdfcf2aeeb6195563691bc38288d6d6f0d7.tar.gz
use 4-argument select() rather than SIGALRM for readability
Diffstat (limited to 'perl5')
-rw-r--r--perl5/Local/Interactive.pm24
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;