Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
spt_writex(2) OSS System Calls Reference Manual
described in the open(2) reference page).
The O_NONBLOCK flag is effective only on pipes, FIFOs, sockets, and terminal device files
(Telserv and OSSTTY processes).
Write requests to a pipe or a FIFO file are handled the same way as write requests to a regular file
with these exceptions:
• No file offset is associated with a pipe; therfore, each spt_writex() request appends to
the end of the pipe.
• If the size of the spt_writex() request is less than or equal to the value of the PIPE_BUF
system variable, the spt_writex() function is guaranteed to be atomic. The data is not
interleaved with data from other processes doing writes on the same pipe.
• If the size of the spt_writex() request is greater than the value of the PIPE_BUF system
variable, the file system attempts to resize the pipe buffer from 2 * PIPE_BUF to 65,536
bytes. If the resizing is successful, the file system performs atomic writes of up to 32,768
bytes and can transfer up to 52 kilobytes of data from the pipe buffer on subsequent
spt_readx() or spt_readvx() calls by the client.
If the file system cannot resize the buffer, it continues to use the existing buffer. A
second attempt at resizing occurs after approximately a minute.
Writes of greater than PIPE_BUF bytes can have data interleaved, on arbitrary boun-
daries, with writes by other processes, whether or not the O_NONBLOCK flag is set.
• If the O_NONBLOCK flag is not set, a spt_writex() request to a full pipe causes the
process to block until enough space becomes available to handle the entire request.
• If the O_NONBLOCK flag is set, spt_writex() requests are handled differently:
— The spt_writex() function does block the process.
— spt_writex() requests for PIPE_BUF or fewer bytes either succeed completely
and return the value of the nbytes parameter, or return the value -1 and set errno
to [EAGAIN].
—Aspt_writex() request for greater than PIPE_BUF bytes either transfers what it
can and returns the number of bytes written, or transfers no data and returns the
value -1 with errno set to [EAGAIN]. Also, if a request is greater than
PIPE_BUF bytes and all data previously written to the pipe has been read,
spt_writex() transfers at least PIPE_BUF bytes.
When you attempt to write to a file descriptor (other than a pipe or a FIFO file) for a special char-
acter device (a terminal) that supports nonblocking writes and cannot accept data immediately:
• If the O_NONBLOCK flag is clear, the spt_writex() function blocks until the data can
be accepted.
• If the O_NONBLOCK flag is set, the spt_writex() function returns the value -1 and
errno
is set to [EAGAIN].
When
you attempt to write to a socket with no space available for data:
• If the O_NONBLOCK flag is not set, the spt_writex() function blocks until space
becomes available.
• If the O_NONBLOCK flag is set, the spt_writex() function returns the value -1 and sets
errno to [EAGAIN]. The O_NONBLOCK flag has no effect if space is available.
7−484 Hewlett-Packard Company 527186-023