


      WRITE(2)                    (UNIX 5.0)                   WRITE(2)



      NAME
           write - write on a file

      SYNTAX
           int write (fildes, buf, nbyte)
           int fildes;
           char *buf;
           unsigned nbyte;

      DESCRIPTION
           Fildes is a file descriptor obtained from a creat, open,
           dup, or fcntl system call.  Write attempts to write nbyte
           bytes from the buffer pointed to by buf to the file
           associated with the fildes.

           On devices capable of seeking, the actual writing of data
           proceeds from the position in the file indicated by the file
           pointer.  Upon return from write, the file pointer is
           incremented 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.

           A write to a regular file will be blocked if mandatory
           file/record locking is set, see chmod(2), and there is a
           record lock owned by another process on the segment of the
           file to be written.  If O_NDELAY is not set, the write will
           sleep until the blocking record lock is removed.

           If the O_APPEND flag of the file status flags is set, the
           file pointer will be set to the end of the file prior to
           each write.  Write fails and the file pointer remains
           unchanged if any of the following are true:

                Fildes is not a valid file descriptor open for writing.

                An attempt was made to write a file that exceeds the
                process's file size limit or the maximum file size.
                [EFBIG]

                Buf points outside the process's allocated address
                space.  [EFAULT]

                A signal was caught during the write system call.
                [EINTR]

                Mandatory file/record locking was set, O_NDELAY was
                set, and there was a blocking record lock.  [EAGAIN]

                The system record lock table was full, so the write
                could not go to sleep until the blocking record lock
                was removed.  [ENOLCK]



      Page 1                                         (73 A2 02MTA REV1)






      WRITE(2)                    (UNIX 5.0)                   WRITE(2)



                The write was going to go to sleep and cause a deadlock
                situation to occur.  [EDEADLK]

           If a write requests that more bytes be written than there is
           room for only as many bytes as there is room for will be
           written.  For example, suppose there is space for 20 bytes
           more in a file before reaching a limit.  A write of 512
           bytes will return 20.  The next write of a non-zero number
           of bytes will give a failure return (except as noted below).

      RETURN VALUE
           Upon successful completion the number of bytes actually
           written is returned.  Otherwise, -1 is returned and errno is
           set to indicate the error.

      SEE ALSO
           chmod(2), creat(2), dup(2), lseek(2), open(2).






































      Page 2                                         (73 A2 02MTA REV1)



