WRITE(2) DOMAIN/IX SYS5 WRITE(2)
NAME
write - write on a file
USAGE
int write(fildes, buf, nbyte)
int fildes;
char *buf;
unsigned nbyte;
DESCRIPTION
Fildes specifies a file descriptor generated by a creat,
open, dup, fcntl, or pipe system call.
Write attempts to write nbyte bytes from the buffer that buf
points to, to the file associated with the fildes.
On devices capable of seeking, write writes the data begin-
ning at the position in the file that the file pointer
specifies and, on return, increments the file pointer by the
number of bytes actually written.
On devices incapable of seeking, writing always takes place
starting at the current position. The value of a file
pointer associated with such a device is undefined.
If the O_APPEND flag of the file status flags is set, the
file pointer will be set to the end of the file before each
write.
RETURN VALUE
A successful call returns the number of bytes actually writ-
ten. A failed call returns -1 and sets errno as indicated
below.
ERRORS
Write will fail and the file pointer will not change if one
or more of the following is true:
[EBADF] Fildes is not a valid file descriptor open for
writing.
[EPIPE and SIGPIPE signal]
An attempt is made to write to a pipe that is not
open for reading by any process.
[EFBIG] An attempt is made to write a file that exceeds
the process's file size limit or the maximum file
size.
Printed 12/4/86 WRITE-1
WRITE(2) DOMAIN/IX SYS5 WRITE(2)
[EFAULT] Buf points outside the process's allocated address
space.
[EINTR] A signal was caught during the write system call.
If a write requests that more bytes be written than there is
room for (e.g., the physical end of a medium), it will write
as many bytes as there is room for. For example, if there
is space for 20 bytes more in a file before reaching a
limit, a write of 512 bytes will return 20. The next
attempt to write a non-zero number of bytes will return a
failure.
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 zero. If
O_NDELAY is clear, writes to a full pipe (or FIFO) will
block until space becomes available.
RELATED INFORMATION
creat(2), dup(2), lseek(2), open(2), pipe(2),
WRITE-2 Printed 12/4/86