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"
10 read, pread \- read input
14 #include <sys/types.h>
17 ssize_t read(int \fId\fP, void *\fIbuf\fP, size_t \fInbytes\fP)
18 ssize_t pread(int \fId\fP, void *\fIbuf\fP, size_t \fInbytes\fP, off_t \fIoffset\fP)
24 of data from the object referenced by the descriptor
26 into the buffer pointed to by
29 On objects capable of seeking, the
32 given by the pointer associated with
38 the pointer is incremented by the number of bytes actually read.
40 Objects that are not capable of seeking always read from the current
41 position. The value of the pointer associated with such an
44 Upon successful completion,
46 return the number of bytes actually read and placed in the buffer.
47 The system guarantees to read the number of bytes requested if
48 the descriptor references a normal file that has that many bytes left
49 before the end-of-file, but in no other case.
51 If the returned value is 0, then
52 end-of-file has been reached.
56 system call performs the same functions, but reads from the specified
57 position in the file without modifying the file pointer.
60 number of bytes actually read is returned.
61 Otherwise, a \-1 is returned and the global variable
63 is set to indicate the error.
68 will fail if one or more of the following are true:
71 \fID\fP is not a valid descriptor open for reading.
74 \fIBuf\fP points outside the allocated address space.
77 An I/O error occurred while reading from the file system.
80 A read from a slow device was interrupted before
81 any data arrived by the delivery of a signal.
84 The file was marked for non-blocking I/O,
85 and no data were ready to be read.
89 system call may also return any of the
101 is currently implemented as a library function instead of a system call.