[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: netfs and O_NONBLOCK

From: Marco Gerards
Subject: Re: netfs and O_NONBLOCK
Date: Tue, 27 Jul 2004 17:26:50 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Roland McGrath <roland@frob.com> writes:

> I'm not sure what you think O_NONBLOCK has to do with io_select.
> io_select's behavior should never be affected by nonblocking mode.

I am sorry, I actually meant io_read.

> The O_NONBLOCK flag bit is strangely overloaded (as specified in POSIX.1).
> It is a state flag for an open file description (i.e. a peropen in our
> implementations' data structures).  However, it is not preserved from the
> flags in an open like e.g. O_APPEND is.

Ok, interesting.  This is what the glibc manual said about this:

 "The open-time flags specify options affecting how `open' will
behave.  These options are not preserved once the file is open.  The
exception to this is `O_NONBLOCK', which is also an I/O operating mode
and so it _is_ saved.  *Note Opening and Closing Files::, for how to
call `open'."


"Note that the `O_NONBLOCK' flag is overloaded as both an I/O
 operating mode and a file name translation flag.  This means that
 specifying `O_NONBLOCK' in `open' also sets nonblocking I/O mode;
 *note Operating Modes::."

> O_NONBLOCK is a flag to the open call itself (in our case, that
> means dir_lookup and fsys_getroot) that says that acquiring the new
> file descriptor (i.e. client port) itself should not block.  Without
> O_NONBLOCK, a terminal device blocks in open until carrier detect,
> for example.  That meaning is unrelated to the file description's
> (peropen's) state of nonblocking i/o mode.  You cannot enable
> nonblocking i/o mode at open time, only with fcntl
> (i.e. io_set_openmodes et al).  This is why O_NONBLOCK belongs in

This is what the glibc manual said about this:

"To open the file without blocking but do normal I/O that blocks, you
 must call `open' with `O_NONBLOCK' set and then call `fcntl' to turn
 the bit off."

I had a look at POSIX (I have searched for O_NONBLOCK and I read the
documentation about open()) and I could not find what you described
here.  Perhaps I read over it because my English is too poor or
because of my limited knowledge of POSIX.

Could you please show me the lines of the POSIX specification where
this is explained or tell me how I misinterpreted the glibc manual?
The way it looks to me it says the exact opposite of what you told me.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]