write.2 (2010 09)

w
write(2) write(2)
[EIO] A physical I/O error has occurred.
[EIO] The process is a member of a background process group attempting to write to its
controlling 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.
[ENOLCK] The system record lock table is full, preventing the write from sleeping until the
blocking record lock is removed.
[ENOSPC] Not enough space on the file system. The process does not possess the
limit
effective privilege to override this restriction.
[ENXIO] A request was made of a non-existent device, or the request was outside the capabil-
ities of the device.
[ENXIO] A hangup occurred on the
STREAM being written to.
[EPIPE] An attempt is made to write to a pipe or FIFO that is not open for reading by any
process, or that only has one end open. A
SIGPIPE signal will also be sent to the
process.
[ERANGE] The transfer request size was outside the range supported by the
STREAMS file
associated with fildes.
Under the following conditions,
writev() fails and sets errno to:
[EFAULT] iov_base or iov points outside of the allocated address space. The reliable detection
of this error is implementation dependent.
[EINVAL] One of the iov_len values in the iov array is negative.
[EINVAL] The sum of the iov_len values in the iov array would overflow an ssize_t .
Under the following conditions, 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}.
Under the following conditions, the
pwrite() function fails, the file pointer remains unchanged and
errno is set to:
[EINVAL] The offset argument is invalid, and the value is negative.
[ESPIPE] The fildes argument is associated with a pipe or FIFO.
Under the following conditions, write() or writev() fails, the file offset is updated to reflect the
amount of data transferred and errno is set to:
[EFAULT] buf points outside the process’s allocated address space. The reliable detection of
this error is implementation dependent.
EXAMPLES
Assuming a process opened a file for writing, the following call to
write() attempts to write mybufsize
bytes to the file from the buffer to which mybuf points.
#include <string.h>
int fildes;
size_t mybufsize;
ssize_t nbytes;
char *mybuf = "aeiou and sometimes y";
mybufsize = (size_t)strlen (mybuf);
nbytes = write (fildes, (void *)mybuf, mybufsize);
WARNINGS
Character special devices, and raw disks in particular, apply constraints on how write() can be used.
See specific Section 7 manual entries for details on particular devices.
AUTHOR
write() was developed by HP, AT&T, and the University of California, Berkeley.
4 Hewlett-Packard Company 4 HP-UX 11i Version 3: September 2010