.th read IV 4/21/86
.sh NAME
read - read from file
.sh SYNOPSIS
read(fildes, buffer, nbytes)
.br
char *buffer;
int fildes, nbytes;
.ft R
.sh DESCRIPTION
A file descriptor is a word returned from a successful open, creat,
dup, pipe, or port call.  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.
.s3
If the returned value is 0, then end-of-file has been reached.
.sh "SEE ALSO"
open (IV), creat (IV), dup (IV), pipe (IV)
.sh DIAGNOSTICS
As mentioned, 0 is returned when the end of the file has been reached.
If the read was otherwise unsuccessful the error bit (c-bit) is set.
Many conditions can generate an error: physical I/O errors, bad buffer
address, preposterous nbytes, file descriptor not that of an input
file.  From C, a -1 return indicates the error.

