Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Sep 2002 06:53:00 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Archie Cobbs <archie@dellroad.org>, Bakul Shah <bakul@bitblocks.com>, freebsd-arch@FreeBSD.ORG
Subject:   Re: /dev/stdout behavior
Message-ID:  <3D7F4ABC.6C84FC79@mindspring.com>
References:  <20020911204937.G1092-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans wrote:
> >     $ uname -a
> >     Linux foobar.packetdesign.com 2.4.9 #19 SMP Mon Oct 29 11:55:31 PST 2001 i686 unknown
> >     $ ./flags
> >     O_NONBLOCK is not set
> 
> This is a bug in Linux IMO.

This is such a misinterpretation of O_NONBLOCK.

The values of O_NDELAY and O_NONBLOCK are identical in their effects,
with the exception of the return value of read(2) or write(2), in the
case of a potential blocking operation:

	O_NDELAY is set:	returns 0.
	O_NONBLOCK is set:	returns -1 and sets errno to EAGAIN.

Other than that they are identical.  So it's reasonable to go looking
at the behaviour of O_NDELAY.

Realize that the existance of the O_NDELAY flag preceeds the ability
to turn it off on an fd once it has been turned on.  That is, there
did not used to be an option to fcntl(, f_SETFL, flasg @ ~O_NDELAY);,
and there did not used to be a FIONBIO ability to turn off the
non-blocking I/O.

You can obtain your own copy of the SVID, and other documents that
are related to the System V ABI, from:

	http://www.caldera.com/developers/devspecs/

Unfortunately, they didn't also make the compliance validcation
suite available online.  8-(.


> /dev/stdout should be as much like the real
> stdout as possible.  E.g., it should share the file offset.  This requires
> its descriptor to be a dup of stdout's descriptor for seekable files, and
> it would be surprising if non-seekable files like ttys were different.
> Sharing of O_NONBLOCK goes with sharing of the file (via diferent
> descriptors).  Some device drivers have broken support for O_NONBLOCK
> (they do extra work to make it per-device), but tty devies get this right.

It's not standardized at all.  The difference seems to be that
FreeBSD takes it as an alias for a descriptor, whereas Linux takes
it as an alias for the FS object to which the descriptor refers.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D7F4ABC.6C84FC79>