Re: Non-blocking I/O

Chris Adams (cadams@ro.com)
17 Jul 1998 03:37:49 GMT


According to Chris Wedgwood <chris@cybernet.co.nz>:
>Yeah, but things like:
>
> open("/mounts/scsi6/cache/04/D3/0004D396", O_RDONLY|O_NONBLOCK)
>
>block.
>
>Hmm... I guess more importantly, what does POSIX say here about the use of
>O_NONBLOCK with open(2)?

Here is what Unix98 says at
http://www.opengroup.org/onlinepubs/7908799/xsh/open.html

O_NONBLOCK
When opening a FIFO with O_RDONLY or O_WRONLY set:
If O_NONBLOCK is set:
An open() for reading only will return without delay. An open()
for writing only will return an error if no process
currently has the file open for reading.
If O_NONBLOCK is clear:
An open() for reading only will block the calling thread until a
thread opens the file for writing. An open() for writing
only will block the calling thread until a thread opens
the file for reading.
When opening a block special or character special file that
supports non-blocking opens:
If O_NONBLOCK is set:
The open() function will return without blocking for the device
to be ready or available. Subsequent behaviour of the
device is device-specific.
If O_NONBLOCK is clear:
The open() function will block the calling thread until the
device is ready or available before returning.
Otherwise, the behaviour of O_NONBLOCK is unspecified.

-- 
Chris Adams - cadams@ro.com
System Administrator - Renaissance Internet Services
I don't speak for anybody but myself - that's enough trouble.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html