in reply to Re^2: Weirdness with IO::Select and IPC::Open3
in thread Weirdness with IO::Select and IPC::Open3
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Weirdness with IO::Select and IPC::Open3
by rastoboy (Monk) on Mar 23, 2011 at 00:22 UTC |