Rafael Garcia-Suarez <[EMAIL PROTECTED]> writes:

> Change 24194 by [EMAIL PROTECTED] on 2005/04/07 12:42:07
> 
>       Mention that select() returns -1 on error,
>       as suggested by Hernan Perez Masci

Hmmm, returning a TRUE value on failure is quite unperlish.  I wonder
how much software got this wrong?  For instance among the core modules
we find code like this.

Net:::Cmd:

   if (select($rout=$rin, undef, undef, $timeout)) {
       sysread($cmd, $buf="", 1024)
       ...
   }
   else {
       # timeout 
       ...
   }

Net::Ping:

    $nfound = mselect((my $rout=$rbits), undef, undef, $timeout); # Wait for 
packet
    $timeout = $finish_time - &time();    # Get remaining time
    if (!defined($nfound))                # Hmm, a strange error
    {
      $ret = undef;
      $done = 1;
    }
    elsif ($nfound)                     # Got a packet from somewhere
    {
      ...
    } else {     # Oops, timed out
      $done = 1;
    }

> Affected files ...
> 
> ... //depot/perl/pod/perlfunc.pod#461 edit
> 
> Differences ...
> 
> ==== //depot/perl/pod/perlfunc.pod#461 (text) ====
> Index: perl/pod/perlfunc.pod
> --- perl/pod/perlfunc.pod#460~24100~  Wed Mar 30 05:16:52 2005
> +++ perl/pod/perlfunc.pod     Thu Apr  7 05:42:07 2005
> @@ -4603,6 +4603,9 @@
>  is implementation-dependent.  See also L<perlport> for notes on the
>  portability of C<select>.
>  
> +On error, C<select> behaves like the select(2) system call : it returns
> +-1 and sets C<$!>.
> +
>  B<WARNING>: One should not attempt to mix buffered I/O (like C<read>
>  or <FH>) with C<select>, except as permitted by POSIX, and even
>  then only on POSIX systems.  You have to use C<sysread> instead.
> End of Patch.

Reply via email to