term% cat index.txt READ(2) System Calls Manual READ(2)
NAME
read - read from file
SYNOPSIS
read(fildes, buffer, nbytes)
char *buffer;
DESCRIPTION
Read causes data to be read from the open file associated with the file
descriptor. Buffer is the location of nbytes contiguous bytes into
which the input will be placed. It is not guaranteed that all nbytes
bytes will be read; for example if the file refers to a terminal at
most one line will be returned. In any event the number of characters
read is returned.
A return value of 0 is conventionally interpreted as end of file. If
more data is subsequently written on the open file by another process,
then a further read will return it.
SEE ALSO
open(2), creat(2), dup(2), pipe(2), select(2)
DIAGNOSTICS
As mentioned, 0 is returned when the end of the file has been reached.
If the read was otherwise unsuccessful the return value is -1. Many
conditions can generate an error: physical I/O errors, bad buffer ad‐
dress, preposterous nbytes, file descriptor not that of an input file.
READ(2)