Non-compliant FreeBSD behavior?

Garrett Wollman wollman at lcs.mit.edu
Fri Apr 11 15:30:41 PDT 2003


<<On Fri, 11 Apr 2003 13:44:16 -0600 (MDT), "M. Warner Losh" <imp at bsdimp.com> said:

> something subtle I'm missing?  What do the standards have to say about
> this?

The standards do not say anything about FIONBIO or ioctl() in general[1].

As far as O_NONBLOCK goes:

# The I/O mode of a socket is described by the O_NONBLOCK file status
# flag which pertains to the open file description for the socket. This
# flag is initially off when a socket is created, but may be set and
# cleared by the use of the F_SETFL command of the fcntl( ) function.
# When the O_NONBLOCK flag is set, functions that would normally block
# until they are complete shall either return immediately with an error,
# or shall complete asynchronously to the execution of the calling
# process. Data transfer operations (the read( ), write( ), send( ), and
# recv( ) functions) shall complete immediately, transfer only as much
# as is available, and then return without blocking, or return an error
# indicating that no transfer could be made without blocking.  The
# connect( ) function initiates a connection and shall return without
# blocking when O_NONBLOCK is set; it shall return the error
# [EINPROGRESS] to indicate that the connection was initiated
# successfully, but that it has not yet completed.

In addition to this definition, O_NONBLOCK is also defined for SEWERS
endpoints, POSIX message queues, opening fifos and special files, and
reading from and writing to pipes and fifos.  FreeBSD's network stack
does not mention O_NONBLOCK anywhere, but the fcntl() implementation
automatically turns fcntl(fd, F_SETFL, O_NONBLOCK) operations into
ioctl(fd, FIONBIO, &one) operations.  soo_ioctl() should then be
called indirectly to set the SS_NBIO status flag on the socket itself.
At the moment I can't seem to find where connect() actually blocks.

-GAWollman

[1] Actually, ioctl() is defined, as a SEWERS-specific function, which
might as well be completely undefined considering how little of SEWERS
is actually defined in the standard.



More information about the freebsd-standards mailing list