non-blocking IO on pipes

jbray%bbn-unix at sri-unix.UUCP jbray%bbn-unix at sri-unix.UUCP
Wed Oct 5 04:32:00 AEST 1983


From:  James Bray <jbray at bbn-unix>

It would appear that the system III/V write(2) manual page description of
non-blocking and limited writes is incorrect:

" If the file being written is a pipe (or FIFO), no partial writes will
be permitted. Thus, the write will fail if a write of nbytes would exceed
a limit.

If the file being written is a pipe (or FIFO) and the O_NDELAY flag of the
file flag word is set, then write to a full pipe (or FIFO) will return a
count of 0..."

writei() works in an iterative fashion on FIFO-based files if there is some
space, but not enough to accomodate the whole write. If nonblocking IO is
requested, the write will fail as soon as the pipe is full, but this will
occur only after available space has been filled. Also, note that limit
checking occurs only in bmap() when actual expansion of the file is taking
place. Thus, any transfer which involves multiple blocks will proceed until
it reaches the limit; at this point, the system call will return -1 to
the user, but the file will still have been written and expanded up to the
point at which bmap() failed, and the file offset will also be updated. So
in the event of a limit error, "A write of 512 bytes will return 20" would
also seem to be wrong: it will return -1, and u.u_error == EFBIG.

At least, that's what it looks like to me. Please feel free to correct me
if I'm wrong.

--Jim Bray
UUCP: wjh12!bbncca!jbray
ARPA: jbray at bbn-unix



More information about the Comp.unix.wizards mailing list