The purpose of select is to parallelise a few things including reading from the handles identified by its first argument. As such, select should return whenever sysread would return for any of those handles.
sysread obviously returns when provided a write-only handle.
$ perl -E' open(my $fh, ">", "file") or die $!; my $rv = sysread($r[0], $buf, 100); if (!defined($rv)) { say "Error: $!"; } elsif (!$rv) { say "eof"; } else { say "Got $rv bytes"; } ' Error: Bad file descriptor
As such, select should do the same.
$ perl -MIO::Select -E' open(my $fh, ">", "file") or die $!; my @r = IO::Select->new($fh)->can_read(); my $rv = sysread($r[0], $buf, 100); if (!defined($rv)) { say "Error: $!"; } elsif (!$rv) { say "eof"; } else { say "Got $rv bytes"; } ' Error: Bad file descriptor
You're saying select should block forever in the event of an error even though sysread would not. That makes no sense.
In reply to Re^3: Weirdness with IO::Select and IPC::Open3
by ikegami
in thread Weirdness with IO::Select and IPC::Open3
by rastoboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |