Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ read(S) — Xenix 2.3.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

creat(S)

dup(S)

fcntl(S)

ioctl(S)

open(S)

pipe(S)

rdchk(S)

tty(M)



     READ(S)                  XENIX System V                   READ(S)



     Name
          read - Reads from a file.

     Syntax
          int read (fildes, buf, nbyte)
          int fildes;
          char *buf;
          unsigned nbyte;

     Description
          fildes is a file descriptor obtained from a creat, open,
          dup, fcntl, or pipe system call.

          read attempts to read nbyte bytes from the file associated
          with fildes into the buffer pointed to by buf.

          On devices capable of seeking, the read starts at a position
          in the file given by the file pointer associated with
          fildes.  Upon return from read, the file pointer is
          incremented by the number of bytes actually read.

          Devices that are incapable of seeking always read from the
          current position.  The value of a file pointer associated
          with such a file is undefined.

          Upon successful completion, read returns the number of bytes
          actually read and placed in the buffer; this number may be
          less than nbyte if the file is associated with a
          communication line (see ioctl(S) and tty(M)), or if the
          number of bytes left in the file is less than nbyte bytes.
          A value of 0 is returned when an end-of-file has been
          reached.

          When attempting to read from an empty pipe (or FIFO):

               If O_NDELAY is set, the read will return a 0.

               If O_NDELAY is clear, the read will block until data is
               written to the file or the file is no longer open for
               writing.

          When attempting to read a file associated with a character
          special file that has no data currently available:

               If O_NDELAY is set, the read will return a 0.

               If O_NDELAY is clear, the read will block until data
               becomes available.

          read will fail if one or more of the following are true:

               fildes is not a valid file descriptor open for reading.



     Page 1                                           (printed 8/7/87)





     READ(S)                  XENIX System V                   READ(S)



               [EBADF]

               buf points outside the allocated address space.
               [EFAULT]

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

     Return Value
          Upon successful completion a nonnegative integer is returned
          indicating the number of bytes actually read.  Otherwise, -1
          is returned and errno is set to indicate the error.

     See Also
          creat(S), dup(S), fcntl(S), ioctl(S), open(S), pipe(S),
          rdchk(S), tty(M)

     Notes
          Reading a region of a file locked with locking causes read
          to hang indefinitely until the locked region is unlocked.



































     Page 2                                           (printed 8/7/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026