write(2) DG/UX 4.30 write(2)
NAME
write - Write to an object.
SYNOPSIS
int write (fildes, buffer, nbyte)
int fildes;
char buffer[];
unsigned nbyte;
PARAMETERS
fildes An active, valid file descriptor.
buffer User data buffer.
nbyte Size (in bytes) of the user data buffer.
DESCRIPTION
Write transfers <nbyte> bytes of data from the buffer
pointed to by <buffer> into the object associated with
<fildes>.
If <fildes> refers to an object pointer having a current
position attribute and the O_APPEND flag is clear, the write
starts at a position in the object given by that attribute.
If <fildes> refers to an object pointer having a current
position attribute and the O_APPEND flag is set, the
position attribute of the object is set equal to the
object's current size, where the write will start.
If the object pointer has no position attribute, then the
starting write position depends on the type of object being
written.
The behavior of the write call is affected by the object
attribute flag O_NDELAY (see open(2)) associated with
<fildes>.
The behavior of writes to a pipe or FIFO depends on whether
or not the request is for more than PIPE_BUF bytes.
If a write of <nbyte> bytes to a pipe (or FIFO) is
requested, and <nbyte> is less than PIPE_BUF bytes, but
<nbyte> of free space is currently not available in the
pipe, then the following occurs:
If the O_NDELAY flag is clear, the process will block until
at least <nbyte> bytes of free space becomes available in
the pipe, and the write will take place.
If the O_NDELAY flag is set, [EAGAIN] is returned.
Licensed material--property of copyright holder(s) Page 1
write(2) DG/UX 4.30 write(2)
If a write of more than PIPE_BUF bytes is requested, the
following occurs:
If the O_NDELAY flag is clear, the process will block if the
pipe is full. As space becomes available in the pipe, the
data from the write request will be written piecemeal--in
multiple smaller amounts until the request is fulfilled.
Thus, data from a write request of more than PIPE_BUF bytes
may be interleaved on arbitrary byte boundaries with data
written by other processes.
If the O_NDELAY flag is set and the pipe is full, the
process will not block and [EAGAIN] is returned.
If the O_NDELAY flag is set and the pipe is not full, the
process will not block, and as much data as will currently
fit in the pipe will be written and that number of bytes is
returned.
The behavior of the write call is affected by the object
attribute flag O_SYNC associated with <fildes>. This flag
causes the write call to block until both the file data and
file status are physically updated.
When write completes, the position attribute, if it exists,
is incremented by the number of bytes actually written. The
modification time for the file and the changed time for the
file status are updated to reflect the time the write
occurred.
If an error occurs, any changes to the object associated
with <fildes> is defined by the object's type. The default
situation is that the object associated with <fildes> is
unchanged. This may not be the case for some errors on some
types of objects.
If write is successful and O_SYNC is not specified, the data
transferred may not be transferred to long term storage (in
the case of an `ordinary-disk-file' for example). To ensure
this is the case, the fsync operation should be used.
ACCESS CONTROL
<Fildes> must be open for writing.
RETURN VALUE
0..<nbyte> Completed successfully. The number of bytes
actually written is returned.
-1 An error occurred. Errno is set to indicate
the error.
EXCEPTIONS
Licensed material--property of copyright holder(s) Page 2
write(2) DG/UX 4.30 write(2)
Errno may be set to one of the following error codes:
EBADF <Fildes> is not a valid file descriptor open
for writing.
EAGAIN The O_NDELAY flag was set and there was not
enough room in the pipe.
EPIPE and SIGPIPE signal
An attempt is made to write to a pipe that is
not open for reading or a socket of type
SOCK_STREAM that is not connected to a peer
socket.
EFBIG An attempt was made to write a file that
exceeds the process's file size limit or the
maximum file size.
EFAULT <Buffer> points outside the process's
allocated address space.
EINTR A signal was caught during the write system
call.
ENOLOCK A lock required to complete the call can not
be allocated from the system lock table.
EDEADLK <fildes> refers to a file that has mandatory
record locking enabled and the read would
produce a deadlock condition.
SEE ALSO
The related manual sections: creat(2), dup(2), dup2(2),
fcntl(2), ioctl(2), lseek(2), open(2), pipe(2), select(2),
socket(2), socketpair(2), ulimit(2), writev(2).
Licensed material--property of copyright holder(s) Page 3