source: trunk/minix/man/man2/read.2@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.0 KB
RevLine 
[9]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.
4.\"
5.\" @(#)read.2 6.6 (Berkeley) 5/23/86
6.\"
7.TH READ 2 "May 23, 1986"
8.UC 4
9.SH NAME
10read \- read input
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <unistd.h>
16
17ssize_t read(int \fId\fP, void *\fIbuf\fP, size_t \fInbytes\fP)
18.fi
19.SH DESCRIPTION
20.B Read
21attempts to read
22.I nbytes
23of data from the object referenced by the descriptor
24.I d
25into the buffer pointed to by
26.IR buf .
27.PP
28On objects capable of seeking, the
29.B read
30starts at a position
31given by the pointer associated with
32.IR d
33(see
34.BR lseek (2)).
35Upon return from
36.BR read ,
37the pointer is incremented by the number of bytes actually read.
38.PP
39Objects that are not capable of seeking always read from the current
40position. The value of the pointer associated with such an
41object is undefined.
42.PP
43Upon successful completion,
44.B read
45return the number of bytes actually read and placed in the buffer.
46The system guarantees to read the number of bytes requested if
47the descriptor references a normal file that has that many bytes left
48before the end-of-file, but in no other case.
49.PP
50If the returned value is 0, then
51end-of-file has been reached.
52.SH "RETURN VALUE
53If successful, the
54number of bytes actually read is returned.
55Otherwise, a \-1 is returned and the global variable
56.B errno
57is set to indicate the error.
58.SH "ERRORS
59.B Read
60will fail if one or more of the following are true:
61.TP 15
62[EBADF]
63\fID\fP is not a valid descriptor open for reading.
64.TP 15
65[EFAULT]
66\fIBuf\fP points outside the allocated address space.
67.TP 15
68[EIO]
69An I/O error occurred while reading from the file system.
70.TP 15
71[EINTR]
72A read from a slow device was interrupted before
73any data arrived by the delivery of a signal.
74.TP 15
75[EAGAIN]
76The file was marked for non-blocking I/O,
77and no data were ready to be read.
78.SH "SEE ALSO"
79.BR dup (2),
80.BR fcntl (2),
81.BR open (2),
82.BR pipe (2),
83.BR write (2).
Note: See TracBrowser for help on using the repository browser.