1 .\" $NetBSD: poll.2,v 1.3 1996/09/07 21:53:08 mycroft Exp $
2 .\" $FreeBSD: src/lib/libc/sys/poll.2,v 1.4.2.3 2001/12/14 18:34:01 ru Exp $
3 .\" $DragonFly: src/lib/libc/sys/poll.2,v 1.7 2008/05/25 14:04:32 swildner Exp $
5 .\" Copyright (c) 1996 Charles M. Hannum. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by Charles M. Hannum.
18 .\" 4. The name of the author may not be used to endorse or promote products
19 .\" derived from this software without specific prior written permission.
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 .Nd synchronous I/O multiplexing
46 .Fa "struct pollfd *fds"
52 .Fa "struct pollfd *fds"
54 .Fa "const struct timespec *timeout"
55 .Fa "const sigset_t *newsigmask"
61 examine a set of file descriptors to see if some of them are ready for
65 argument is a pointer to an array of pollfd structures as defined in
70 argument determines the size of the
75 int fd; /* file descriptor */
76 short events; /* events to look for */
77 short revents; /* events returned */
84 .Bl -tag -offset indent -width ".Fa revents"
86 File descriptor to poll.
87 If fd is equal to -1 then
89 is cleared (set to zero), and that pollfd is not checked.
94 Events which may occur.
102 have the following bits:
103 .Bl -tag -offset indent -width ".Dv POLLRDNORM"
105 Data other than high priority data may be read without blocking.
107 Normal data may be read without blocking.
109 Data with a non-zero priority may be read without blocking.
111 High priority data may be read without blocking.
114 Normal data may be written without blocking.
116 Data with a non-zero priority may be written without blocking.
118 An exceptional condition has occurred on the device or socket.
119 This flag is always checked, even if not present in the
123 The device or socket has been disconnected.
124 This flag is always checked, even if not present in the
131 should never be present in the
133 bitmask at the same time.
135 The file descriptor is not open.
136 This flag is always checked, even if not present in the
145 it specifies a maximum interval to
146 wait for any file descriptor to become ready, in milliseconds.
151 the poll blocks indefinitely.
156 will return without blocking.
160 system call can be used to safely wait until either a set of file
161 descriptors becomes ready, or until a signal is caught.
167 .Vt "const struct timespec"
172 A null pointer may be passed to indicate that
174 should wait indefinitely.
177 specifies a signal mask which is set while waiting for input.
180 returns, the original signal mask is restored.
183 returns the number of descriptors that are ready for I/O, or -1 if an
185 If the time limit expires,
190 returns with an error,
191 including one due to an interrupted call,
194 array will be unmodified.
196 This implementation differs from the historical one in that a given
197 file descriptor may not cause
199 to return with an error.
200 In cases where this would have happened in the historical implementation
201 (e.g.\& trying to poll a
203 descriptor), this implementation instead copies the
208 Attempting to perform I/O on this descriptor will then return an error.
209 This behaviour is believed to be more useful.
213 implementation uses a precise timeout which is intended to mimic the
214 behaviour of this syscall in Linux.
223 points outside the process's allocated address space.
225 A signal was delivered before the time limit expired and
226 before any of the selected events occurred.
228 The specified time limit is negative.
242 function call appeared in
244 This manual page was taken from
248 function first appeared in
251 The distinction between some of the fields in the
255 bitmasks is really not useful without STREAMS.
256 The fields are defined for compatibility with existing software.