Subject: Re: Why does read() block on I/O error?
To: Jaromir Dolecek <>
From: Greg A. Greg A. Woods; Planix, Inc. <>
List: current-users
Date: 07/09/2002 12:34:49
[ On Tuesday, July 9, 2002 at 09:16:39 (+0200), Jaromir Dolecek wrote: ]
> Subject: Re: Why does read() block on I/O error?
> O_NONBLOCK has only effect on IPC descriptors, like sockets and
> pipes. It doesn't have any effects for file descriptors.

It also works for file descriptors open on "slow" devices, which
presumably a CD-ROM could be considered to be, at least when accessed in
any sequential style....

     If the O_NONBLOCK flag is specified, do not wait for the device or file
     to be ready or available.  If the open() call would result in the process
     being blocked for some reason (e.g., waiting for carrier on a dialup
     line, or the file is currently locked), open() returns immediately with
     an error code of -1, setting errno to EAGAIN.  This flag also has the ef-
     fect of making all subsequent I/O on the open file non-blocking.

I believe it requires device driver support though, and I don't imagine
the various CD-ROM devices have such support.

(It can also work in conjunction with the lock-on-open flags O_SHLOCK
and O_EXLOCK.)

								Greg A. Woods

+1 416 218-0098;            <>;           <>
Planix, Inc. <>; VE3TCP; Secrets of the Weird <>