V7/usr/man/man2/read.2
.TH READ 2
.SH NAME
read \- read from file
.SH SYNOPSIS
.B read(fildes, buffer, nbytes)
.br
.B char *buffer;
.SH DESCRIPTION
A file descriptor is a word
returned from a successful
.I "open, creat, dup,"
or
.I pipe
call.
.I Buffer
is the location of
.I nbytes
contiguous
bytes into which the input will be placed.
It is not guaranteed
that all
.I nbytes
bytes will be read; for example
if the file refers to a typewriter at most one line
will be returned.
In any event the number of characters read is returned.
.PP
If the returned value is 0, then
end-of-file has been reached.
.SH "SEE ALSO"
open(2), creat(2), dup(2), pipe(2)
.SH 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 address,
preposterous
.I nbytes,
file descriptor not that of
an input file.
.SH ASSEMBLER
(read = 3.)
.br
(file descriptor in r0)
.br
.B sys read; buffer; nbytes
.br
(byte count in r0)