OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [doc/] [manpages/] [sys/] [poll.2] - Blame information for rev 229

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
.\"     $OpenBSD: poll.2,v 1.11 2001/08/11 08:13:18 fgsch Exp $
2
.\"
3
.\" Copyright (c) 1994 Jason R. Thorpe
4
.\" All rights reserved.
5
.\"
6
.\" Redistribution and use in source and binary forms, with or without
7
.\" modification, are permitted provided that the following conditions
8
.\" are met:
9
.\" 1. Redistributions of source code must retain the above copyright
10
.\"    notice, this list of conditions and the following disclaimer.
11
.\" 2. Redistributions in binary form must reproduce the above copyright
12
.\"    notice, this list of conditions and the following disclaimer in the
13
.\"    documentation and/or other materials provided with the distribution.
14
.\" 3. All advertising materials mentioning features or use of this software
15
.\"    must display the following acknowledgement:
16
.\"     This product includes software developed by Jason R. Thorpe.
17
.\" 4. The name of the author may not be used to endorse or promote products
18
.\"    derived from this software without specific prior written permission.
19
.\"
20
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25
.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27
.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
.\"
31
.Dd December 13, 1994
32
.Dt POLL 2
33
.Os
34
.Sh NAME
35
.Nm poll
36
.Nd synchronous I/O multiplexing
37
.Sh SYNOPSIS
38
.Fd #include 
39
.Ft int
40
.Fn poll "struct pollfd *fds" "int nfds" "int timeout"
41
.Sh DESCRIPTION
42
.Fn poll
43
provides a mechanism for reporting I/O conditions across a set of file
44
descriptors.
45
.Pp
46
The arguments are as follows:
47
.Bl -tag -width timeout
48
.It Pa fds
49
Points to an array of
50
.Nm pollfd
51
structures, which are defined as:
52
.Bd -literal -offset indent
53
struct pollfd {
54
        int fd;
55
        short events;
56
        short revents;
57
};
58
.Ed
59
.Pp
60
The
61
.Pa fd
62
member is an open file descriptor.
63
The
64
.Pa events
65
and
66
.Pa revents
67
members are bitmasks of conditions to monitor and conditions found,
68
respectively.
69
.It Pa nfds
70
The number of
71
.Nm pollfd
72
structures in the array.
73
.It Pa timeout
74
Maximum interval to wait for the poll to complete, in milliseconds.
75
If this value is 0, then
76
.Fn poll
77
will return immediately.
78
If this value is INFTIM (-1),
79
.Fn poll
80
will block indefinitely until a condition is found.
81
.El
82
.Pp
83
The calling process sets the
84
.Pa events
85
bitmask and
86
.Fn poll
87
sets the
88
.Pa revents
89
bitmask.
90
Each call to
91
.Fn poll
92
resets the
93
.Pa revents
94
bitmask for accuracy.
95
The condition flags in the bitmasks are defined as:
96
.Bl -tag -width POLLRDNORM
97
.It Nm POLLIN
98
Data is available on the file descriptor for reading.
99
.It Nm POLLNORM
100
Same as
101
.Nm POLLIN .
102
.It Nm POLLPRI
103
Same as
104
.Nm POLLIN .
105
.It Nm POLLOUT
106
Data can be written to the file descriptor without blocking.
107
.It Nm POLLERR
108
This flag is not used in this implementation and is provided only for source
109
code compatibility.
110
.It Nm POLLHUP
111
The file descriptor was valid before the polling process and invalid after.
112
Presumably, this means that the file descriptor was closed sometime during
113
the poll.
114
.It Nm POLLNVAL
115
The corresponding file descriptor is invalid.
116
.It Nm POLLRDNORM
117
Same as
118
.Nm POLLIN .
119
.It Nm POLLRDBAND
120
Same as
121
.Nm POLLIN .
122
.It Nm POLLWRNORM
123
Same as
124
.Nm POLLOUT .
125
.It Nm POLLWRBAND
126
Same as
127
.Nm POLLOUT .
128
.It Nm POLLMSG
129
This flag is not used in this implementation and is provided only for source
130
code compatibility.
131
.El
132
.Pp
133
All flags except
134
.Nm POLLIN ,
135
.Nm POLLOUT ,
136
and their synonyms are for use only in the
137
.Pa revents
138
member of the
139
.Nm pollfd
140
structure.
141
An attempt to set any of these flags in the
142
.Pa events
143
member will generate an error condition.
144
.Pp
145
In addition to I/O multiplexing,
146
.Fn poll
147
can be used to generate simple timeouts.
148
This functionality may be achieved by passing a null pointer for
149
.Pa fds .
150
.Sh WARNINGS
151
The
152
.Nm POLLHUP
153
flag is only a close approximation and may not always be accurate.
154
.Sh RETURN VALUES
155
Upon error,
156
.Fn poll
157
returns a \-1 and sets the global variable
158
.Va errno
159
to indicate the error.
160
If the timeout interval was reached before any events occurred,
161
a 0 is returned.
162
Otherwise,
163
.Fn poll
164
returns the number of file descriptors for which
165
.Pa revents
166
is non-zero.
167
.Sh ERRORS
168
.Fn poll
169
will fail if:
170
.Bl -tag -width "EINVAL   "
171
.It Bq Er EINVAL
172
.Pa nfds
173
was either a negative number or greater than the number of available
174
file descriptors.
175
.It Bq Er EINVAL
176
An invalid flags was set in the
177
.Pa events
178
member of the
179
.Nm pollfd
180
structure.
181
.It Bq Er EINVAL
182
The timeout passed to
183
.Fn poll
184
was too large.
185
.It Bq Er EAGAIN
186
Resource allocation failed inside of
187
.Fn poll .
188
Subsequent calls to
189
.Fn poll
190
may succeed.
191
.It Bq Er EINTR
192
.Fn poll
193
caught a signal during the polling process.
194
.El
195
.Sh SEE ALSO
196
.Xr poll 2 ,
197
.Xr select 2 ,
198
.Xr sysconf 3
199
.Sh HISTORY
200
A
201
.Fn poll
202
system call appeared in
203
.At V .

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.