Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (w) writev(2)
Upon successful completion, the writev() function returns the number of bytes actually written
to the le associated with ledes.
If the O_APPEND status ag of the le is set, the le offset is set to the end of the le prior to
each write.
If the O_SYNC status ag of the le is set and ledes refers to a regular le, a successful wri-
tev() call does not return until the data is delivered to the underlying hardware (as described in
the open(2) reference page).
The O_NONBLOCK ag is effective only on pipes, FIFOs, sockets, and terminal device les
(Telserv or OSSTTY processes).
Write requests to a pipe or FIFO le are handled the same as writes to a regular le with these
exceptions:
No le offset is associated with a pipe; therfore, each writev() request appends to the
end of the pipe.
If the size of the writev( ) request is less than or equal to the value of the PIPE_BUF
system variable, the writev() function is guaranteed to be atomic. The data is not inter-
leaved with data from other processes doing writes on the same pipe.
If the size of the writev( ) request is greater than the value of the PIPE_BUF system
variable, the le system attempts to resize the pipe buffer from 2 * PIPE_BUF to 65,536
bytes. If the resizing is successful, the le 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
read() or readv() calls by the client.
If the le system cannot resize the buffer, it continues to use the existing buffer. A
second attempt at resizing occurs after approximately a minute elapses.
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 ag is set.
If the O_NONBLOCK ag is not set, a writev() request to a full pipe causes the process
to block until enough space becomes available to handle the entire request.
If the O_NONBLOCK ag is set, writev() requests are handled differently in these
ways:
The writev() function does block the process.
writev() requests for PIPE_BUF or fewer bytes either succeed completely and
return the number of bytes written, or return the value -1 and set errno to
[EAGAIN].
A writev( ) 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, writev() transfers
at least PIPE_BUF bytes.
When attempting to write to a socket with no space available for data:
If the O_NONBLOCK ag is not set, the writev() function blocks until space becomes
available.
If the O_NONBLOCK ag is set, the writev() function returns the value -1 and sets
errno to [EAGAIN]. The O_NONBLOCK ag has no effect if there is space available.
527186-003 Hewlett-Packard Company 1019