READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) NAME NAME NAME NAME read - read from file SYNOPSIS SYNOPSIS SYNOPSIS SYNOPSIS int read (fildes, buf, nbyte) int fildes; char *buf; unsigned nbyte; DESCRIPTION DESCRIPTION DESCRIPTION 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 (2) and tty (4)), 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 tty 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. Hewlett-Packard - 1 - (printed 12/11/84) READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) READ(2) HP Integral PC READ(2) [EBADF] Buf points outside the allocated address space. [EFAULT] RETURN VALUE RETURN VALUE RETURN VALUE RETURN VALUE Upon successful completion a non-negative integer is returned indicating the number of bytes actually read. Otherwise, a -1 is returned and errno is set to indicate the error. DIAGNOSTICS DIAGNOSTICS DIAGNOSTICS DIAGNOSTICS Information read from disc by the operating system is cached in memory for the purposes of speeding up access to information in files. Consequently, not every read done of a file causes the system to go out to the physical medium to get data. If this becomes necessary, one should do a sync before the read is executed. SEE ALSO SEE ALSO SEE ALSO SEE ALSO creat(2), dup(2), fcntl(2), ioctl(2), open(2), pipe(2), tty(4). Hewlett-Packard - 2 - (printed 12/11/84)