`exceptfds' argument to select()

Chris Torek chris at mimsy.umd.edu
Wed May 2 20:00:33 AEST 1990


In article <6739 at blake.acs.washington.edu> wiml at blake.acs.washington.edu
(William Lewis) writes:
>... what exactly is the third (fds *) argumnt to select(), called
>'exceptfds' in the manual, do?

Everything or nothing or maybe something.  (Keep reading; there really
is some information here :-) )

>The manual says it signals an 'exceptional condition' on the socket,
>but does not say what an exceptional condition is.

An `exceptional condition' is whatever the code for the object
underlying a given file descriptor wants to call `exceptional'.  A
character device driver, for instance, that connects to a weather
monitor could define `exceptional condition' as `tornado headed for
computer center'.

Now, at it happens, the code for sockets says `there is an exception'
whenever there is any out of band data on the socket.  It does NOT
(and nothing should) say `exception' when a peer closes a socket,
because that is a normal condition that shows up as end-of-file.
The latter is indicated as `ready for read', since `select for
read' really means `ask whether read() will not block'.  EOF does
not block, so it is `ready to be read'.  On EOF, programs should
close the (now dead) socket and stop selecting on that socket.

The code for other drivers does other things.  In particular, the
pty driver says `exception' when there is a `control byte' available
in TIOCPKT or TIOCUCNTL mode.  No other standard driver does anything
special.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list