Skip to content

Commit

Permalink
Don't block IO::Handle.get on TTYs after we reached EOF
Browse files Browse the repository at this point in the history
Fixes RT#130086: https://rt.perl.org/Ticket/Display.html?id=130086

We don't block on non-TTYs nor do we block with other method such
as .read. While TTYs require an extra read to figure out when they
reach EOF, once we know we're at EOF, there's no point trying to
read again.
  • Loading branch information
zoffixznet committed Jan 20, 2018
1 parent f3efe5e commit 359efef
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/core/IO/Handle.pm
Expand Up @@ -294,17 +294,19 @@ my class IO::Handle {

method !get-line-slow-path() {
my $line := Nil;
loop {
my $buf := self.read-internal(0x100000);
if $buf.elems {
$!decoder.add-bytes($buf);
$line := $!decoder.consume-line-chars(:$!chomp);
last if nqp::isconcrete($line);
}
else {
$line := $!decoder.consume-line-chars(:$!chomp, :eof)
unless self.eof-internal && $!decoder.is-empty;
last;
unless self.eof-internal && $!decoder.is-empty {
loop {
my $buf := self.read-internal(0x100000);
if $buf.elems {
$!decoder.add-bytes($buf);
$line := $!decoder.consume-line-chars(:$!chomp);
last if nqp::isconcrete($line);
}
else {
$line := $!decoder.consume-line-chars(:$!chomp, :eof)
unless self.eof-internal && $!decoder.is-empty;
last;
}
}
}
$line
Expand Down

0 comments on commit 359efef

Please sign in to comment.