questions about select and non-blocking I/O

Marshall Rose mrose at UDel-Dewey.ARPA
Wed Jul 17 01:45:27 AEST 1985


    Actually, things are worse off than you think.  If you set
    non-blocking I/O, then select() ALWAYS returns immediately saying
    that a descriptor can be written.  I found this out the hard way:

	 I had a telnet connection which I suspended, even though the
	 remote host was generating output to the network at the time.
	 As soon as all the buffers (network, pty, etc.) had filled up
	 so that the write() from telnetd actually returned
	 EWOULDBLOCK, then telnetd ate the machine alive in a very
	 tight loop: do select() on writing to the network, select()
	 IMMEDIATELY returns, do write() on network, write() fails with
	 EWOULDBLOCK, loop back to select...

    I fixed the problem by removing the two FIONBIO ioctl()s in
    telnetd.  Now it works "right".

    Moral of the story: use select() or ioctl(,FIONBIO,), not both for
    descriptors you want to write().

/mtr



More information about the Comp.unix.wizards mailing list