HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
w
write(2) write(2)
RETURN VALUE
Upon successful completion, write() and pwrite() will return the number of bytes actually written to
the file associated with fildes. This number will never be greater than nbyte. Otherwise, −1 is returned
and
errno is set to indicate the error.
Upon successful completion, writev() returns the number of bytes actually written. Otherwise, it
returns a value of −1, the file-pointer remains unchanged, and
errno is set to indicate an error.
ERRORS
The
write(), pwrite() and writev() functions will fail if:
[EAGAIN] The
O_NONBLOCK flag is set for the file descriptor and the process would be delayed
in the
write() operation.
[EBADF] The fildes argument is not a valid file descriptor open for writing.
[EFBIG] An attempt was made to write a file that exceeds the implementation-dependent max-
imum file size or the process’ file size limit.
[EINTR] The write operation was terminated due to the receipt of a signal, and no data was
transferred.
[EIO] A physical I/O error has occurred.
[EIO] The process is a member of a background process group attempting to write to its con-
trolling terminal, TOSTOP is set, the process is neither ignoring nor blocking
SIGTTOU and the process group of the process is orphaned. This error may also be
returned under implementation-dependent conditions.
[ENOSPC] There was no free space remaining on the device containing the file.
[EPIPE] An attempt is made to write to a pipe or FIFO that is not open for reading by any pro-
cess, or that only has one end open. A SIGPIPE signal will also be sent to the pro-
cess.
[ERANGE] The transfer request size was outside the range supported by the
STREAMS file asso-
ciated with fildes.
The
writev() function will fail if:
[EINVAL] The sum of the iov_len values in the iov array would overflow an ssize_t.
The
write(), pwrite() and writev() functions may fail if:
[EINVAL] The STREAM or multiplexer referenced by fildes is linked (directly or indirectly)
downstream from a multiplexer.
[ENXIO] A request was made of a non-existent device, or the request was outside the capabili-
ties of the device.
[ENXIO] A hangup occurred on the
STREAM being written to.
A write to a STREAMS file may fail if an error message has been received at the
STREAM head. In this
case,
errno is set to the value included in the error message.
The writev() function may fail and set errno to:
[EINVAL] The iovcnt argument was less than or equal to 0, or greater than {IOV_MAX}.
The pwrite() function fails and the file pointer remains unchanged if:
[EINVAL] The offset argument is invalid, The value is negative. [ESPIPE] fildes is associated
with a pipe or FIFO.
SEE ALSO
chmod(2), creat(2), dup(2), fcntl(2), getrlimit(2), lseek(2), open(2), pipe(2), ulimit(2), <limits.h>, <stropts.h>,
<sys/uio.h>, <unistd.h>.
CHANGE HISTORY
First released in Issue 1.
Derived from Issue 1 of the SVID.
Section 2−−482 Hewlett-Packard Company − 3 − HP-UX 11i Version 1: September 2005