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