Michele Bini wrote:
> > > How can it be? select() returns 1 (as if fd 0 had
> > > some data pending, but read() returns 0 and doesn't
> > > read any byte)
> >
> > When read() returns 0 it is indicating EOF.
> >
> > Note that select() doesn't indicate that data is available: it
> > indicates that calling read() on the descriptor won't block.
>
> The manpage doesn't seem to say so:
>
> Three independent sets of descriptors are watched. Those
> listed in readfds will be watched to see if characters
> become available for reading, those in writefds will be
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It depends upon how you interpret this. If you interpret `available
for reading' as meaning `read() won't block', then it's accurate.
> watched to see if it is ok to immediately write on them,
> and those in exceptfds will be watched for exceptions. On
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> exit, the sets are modified in place to indicate which
> descriptors actually changed status.
>
> If EOF is an exception I would expect to be noticed only if I
> put fd 0 in the exceptfds set.
EOF isn't an exception. IIRC, out-of-band (OOB) data on a socket
counts as an exception. I don't know what else does.
Note that manpages are for reference; they aren't intended to form a
tutorial. You can generally get more descriptive information in the
Info files, e.g. with
M-x Info-goto-node RET (libc.info)Waiting for I/O RET
in (X)Emacs, or with
info libc
g
Waiting for I/O
--
Glynn Clements <[EMAIL PROTECTED]>