1 .\" Copyright (c) 1980 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)read.2 6.6 (Berkeley) 5/23/86
7 .TH READ 2 "May 23, 1986"
14 #include <sys/types.h>
17 ssize_t read(int \fId\fP, void *\fIbuf\fP, size_t \fInbytes\fP)
23 of data from the object referenced by the descriptor
25 into the buffer pointed to by
28 On objects capable of seeking, the
31 given by the pointer associated with
37 the pointer is incremented by the number of bytes actually read.
39 Objects that are not capable of seeking always read from the current
40 position. The value of the pointer associated with such an
43 Upon successful completion,
45 return the number of bytes actually read and placed in the buffer.
46 The system guarantees to read the number of bytes requested if
47 the descriptor references a normal file that has that many bytes left
48 before the end-of-file, but in no other case.
50 If the returned value is 0, then
51 end-of-file has been reached.
54 number of bytes actually read is returned.
55 Otherwise, a \-1 is returned and the global variable
57 is set to indicate the error.
60 will fail if one or more of the following are true:
63 \fID\fP is not a valid descriptor open for reading.
66 \fIBuf\fP points outside the allocated address space.
69 An I/O error occurred while reading from the file system.
72 A read from a slow device was interrupted before
73 any data arrived by the delivery of a signal.
76 The file was marked for non-blocking I/O,
77 and no data were ready to be read.