WRITE(2) DOMAIN/IX Reference Manual (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 performs the actual
writing of data from the position in the file that the file
pointer specifies. Upon return from write, the file pointer
increments 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
Upon successful completion, write returns the number of
bytes actually written. Otherwise, it returns -1 and sets
errno to indicate the error.
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' file size limit or the
maximum file size.
[EFAULT] Buf points outside the process' allocated
address space.
Printed 5/10/85 WRITE-1
WRITE(2) DOMAIN/IX Reference Manual (SYS5) WRITE(2)
[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. Otherwise,
(FIFO) will block until space becomes available.
RELATED INFORMATION
creat(2), dup(2), lseek(2), open(2), pipe(2),
WRITE-2 Printed 5/10/85