Skip to content

PerlIO: don't set the error flag when reading on an EAGAIN #23314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions perlio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4466,8 +4466,7 @@ PerlIOBuf_fill(pTHX_ PerlIO *f)
if (avail <= 0) {
if (avail == 0)
PerlIOBase(f)->flags |= PERLIO_F_EOF;
else
{
else if (errno != EAGAIN) {
PerlIOBase(f)->flags |= PERLIO_F_ERROR;
PerlIO_save_errno(f);
}
Expand Down
37 changes: 36 additions & 1 deletion t/io/perlio.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BEGIN {
skip_all_without_perlio();
}

plan tests => 48;
plan tests => 56;

use_ok('PerlIO');

Expand Down Expand Up @@ -246,6 +246,41 @@ EOP
ok !$main::PerlIO_code_injection, "Can't inject code via PerlIO->import";
}

SKIP:
{
skip_without_dynamic_extension("IO", 8);

skip("Win32 can't make a pipe non-blocking", 8)
if $^O eq "MSWin32";

$Config{d_pipe}
or skip("No pipe", 8);

require IO::Select;

my ($in, $out);
pipe($in, $out)
or skip("Cannot pipe: $!", 8);

$in->blocking(0)
or skip("Cannot make pipe non-blocking", 8);

my $line = <$in>;
is($line, undef, "error reading (readline)");
ok(!$in->error, "but did not set error flag (readline)");
{
local $::TODO = "read() uses the error flag to detect errors";
is(read($in, my $buf, 10), undef, "error reading (read)");
}
ok(!$in->error, "but did not set error flag (read)");
close $out;
$line = <$in>;
is($line, undef, "nothing to read, but eof");
ok(!$in->error, "still did not set error flag");
ok($in->eof, "did set eof");
ok(close($in), "close success");
}

END {
unlink_all $txt;
unlink_all $bin;
Expand Down
Loading