BSD 3 development
[unix-history] / usr / man / man2 / read.2
CommitLineData
eb676f2b
BJ
1.TH READ 2
2.SH NAME
3read \- read from file
4.SH SYNOPSIS
5.B read(fildes, buffer, nbytes)
6.br
7.B char *buffer;
8.SH DESCRIPTION
9A file descriptor is a word
10returned from a successful
11.I "open, creat, dup,"
12or
13.I pipe
14call.
15.I Buffer
16is the location of
17.I nbytes
18contiguous
19bytes into which the input will be placed.
20It is not guaranteed
21that all
22.I nbytes
23bytes will be read; for example
24if the file refers to a typewriter at most one line
25will be returned.
26In any event the number of characters read is returned.
27.PP
28If the returned value is 0, then
29end-of-file has been reached.
30.PP
31If very large data files are to be accessed randomly, see
32.I vread (2)
33.SH "SEE ALSO"
34open(2), creat(2), dup(2), pipe(2), vread(2)
35.SH DIAGNOSTICS
36As mentioned,
370 is returned when the end of the file has been reached.
38If the read was otherwise unsuccessful
39the return value is \-1.
40Many conditions
41can generate an error:
42physical I/O errors, bad buffer address,
43preposterous
44.I nbytes,
45file descriptor not that of
46an input file.
47.SH "ASSEMBLER (PDP-11)"
48(read = 3.)
49.br
50(file descriptor in r0)
51.br
52.B sys read; buffer; nbytes
53.br
54(byte count in r0)