blob: d9d802bb42c0a46e8ebce8083087c8467c72ff8d [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001:mod:`select` --- Waiting for I/O completion
2============================================
3
4.. module:: select
5 :synopsis: Wait for I/O completion on multiple streams.
6
7
Georg Brandl60203b42010-10-06 10:11:56 +00008This module provides access to the :c:func:`select` and :c:func:`poll` functions
Jesus Cead8b9ae62011-11-14 19:07:41 +01009available in most operating systems, :c:func:`devpoll` available on
10Solaris and derivatives, :c:func:`epoll` available on Linux 2.5+ and
Georg Brandl60203b42010-10-06 10:11:56 +000011:c:func:`kqueue` available on most BSD.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000012Note that on Windows, it only works for sockets; on other operating systems,
13it also works for other file types (in particular, on Unix, it works on pipes).
14It cannot be used on regular files to determine whether a file has grown since
15it was last read.
Georg Brandl116aa622007-08-15 14:28:22 +000016
17The module defines the following:
18
19
20.. exception:: error
21
Antoine Pitrou9b7fcf82011-10-12 16:23:02 +020022 A deprecated alias of :exc:`OSError`.
23
24 .. versionchanged:: 3.3
25 Following :pep:`3151`, this class was made an alias of :exc:`OSError`.
Georg Brandl116aa622007-08-15 14:28:22 +000026
27
Jesus Cead8b9ae62011-11-14 19:07:41 +010028.. function:: devpoll()
Jesus Ceaf450c1b2011-11-15 05:42:59 +010029
Jesus Cead8b9ae62011-11-14 19:07:41 +010030 (Only supported on Solaris and derivatives.) Returns a ``/dev/poll``
31 polling object; see section :ref:`devpoll-objects` below for the
32 methods supported by devpoll objects.
33
34 :c:func:`devpoll` objects are linked to the number of file
35 descriptors allowed at the time of instantiation. If your program
36 reduces this value, :c:func:`devpoll` will fail. If your program
Jesus Ceaf450c1b2011-11-15 05:42:59 +010037 increases this value, :c:func:`devpoll` may return an
Jesus Cead8b9ae62011-11-14 19:07:41 +010038 incomplete list of active file descriptors.
39
40 .. versionadded:: 3.3
41
Benjamin Peterson2fb9ae92011-12-27 15:15:41 -060042.. function:: epoll(sizehint=-1, flags=0)
Christian Heimes4fbc72b2008-03-22 00:47:35 +000043
Benjamin Peterson2fb9ae92011-12-27 15:15:41 -060044 (Only supported on Linux 2.5.44 and newer.) Return an edge polling object,
45 which can be used as Edge or Level Triggered interface for I/O
46 events. *sizehint* is deprecated and completely ignored. *flags* can be set
47 to :const:`EPOLL_CLOEXEC`, which causes the epoll descriptor to be closed
48 automatically when :func:`os.execve` is called. See section
49 :ref:`epoll-objects` below for the methods supported by epolling objects.
50
51
52 .. versionchanged:: 3.3
53
54 Added the *flags* parameter.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000055
Christian Heimes4fbc72b2008-03-22 00:47:35 +000056
Georg Brandl116aa622007-08-15 14:28:22 +000057.. function:: poll()
58
59 (Not supported by all operating systems.) Returns a polling object, which
60 supports registering and unregistering file descriptors, and then polling them
61 for I/O events; see section :ref:`poll-objects` below for the methods supported
62 by polling objects.
63
64
Christian Heimesfe337bf2008-03-23 21:54:12 +000065.. function:: kqueue()
Christian Heimes4fbc72b2008-03-22 00:47:35 +000066
Georg Brandle767e042010-07-14 08:00:22 +000067 (Only supported on BSD.) Returns a kernel queue object; see section
Christian Heimesfe337bf2008-03-23 21:54:12 +000068 :ref:`kqueue-objects` below for the methods supported by kqueue objects.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000069
Christian Heimes4fbc72b2008-03-22 00:47:35 +000070
Benjamin Peterson1baf4652009-12-31 03:11:23 +000071.. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)
Christian Heimes4fbc72b2008-03-22 00:47:35 +000072
Georg Brandle767e042010-07-14 08:00:22 +000073 (Only supported on BSD.) Returns a kernel event object; see section
74 :ref:`kevent-objects` below for the methods supported by kevent objects.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000075
Christian Heimes4fbc72b2008-03-22 00:47:35 +000076
Georg Brandl734e2682008-08-12 08:18:18 +000077.. function:: select(rlist, wlist, xlist[, timeout])
Georg Brandl116aa622007-08-15 14:28:22 +000078
Georg Brandl60203b42010-10-06 10:11:56 +000079 This is a straightforward interface to the Unix :c:func:`select` system call.
Georg Brandl116aa622007-08-15 14:28:22 +000080 The first three arguments are sequences of 'waitable objects': either
81 integers representing file descriptors or objects with a parameterless method
Georg Brandl734e2682008-08-12 08:18:18 +000082 named :meth:`fileno` returning such an integer:
83
84 * *rlist*: wait until ready for reading
85 * *wlist*: wait until ready for writing
86 * *xlist*: wait for an "exceptional condition" (see the manual page for what
87 your system considers such a condition)
88
89 Empty sequences are allowed, but acceptance of three empty sequences is
90 platform-dependent. (It is known to work on Unix but not on Windows.) The
91 optional *timeout* argument specifies a time-out as a floating point number
92 in seconds. When the *timeout* argument is omitted the function blocks until
93 at least one file descriptor is ready. A time-out value of zero specifies a
94 poll and never blocks.
Georg Brandl116aa622007-08-15 14:28:22 +000095
96 The return value is a triple of lists of objects that are ready: subsets of the
97 first three arguments. When the time-out is reached without a file descriptor
98 becoming ready, three empty lists are returned.
99
100 .. index::
101 single: socket() (in module socket)
102 single: popen() (in module os)
103
Antoine Pitrou11cb9612010-09-15 11:11:28 +0000104 Among the acceptable object types in the sequences are Python :term:`file
105 objects <file object>` (e.g. ``sys.stdin``, or objects returned by
106 :func:`open` or :func:`os.popen`), socket objects returned by
107 :func:`socket.socket`. You may also define a :dfn:`wrapper` class yourself,
108 as long as it has an appropriate :meth:`fileno` method (that really returns
109 a file descriptor, not just a random integer).
Georg Brandl116aa622007-08-15 14:28:22 +0000110
Georg Brandl116aa622007-08-15 14:28:22 +0000111 .. note::
112
113 .. index:: single: WinSock
114
Georg Brandl734e2682008-08-12 08:18:18 +0000115 File objects on Windows are not acceptable, but sockets are. On Windows,
Georg Brandl60203b42010-10-06 10:11:56 +0000116 the underlying :c:func:`select` function is provided by the WinSock
Georg Brandl734e2682008-08-12 08:18:18 +0000117 library, and does not handle file descriptors that don't originate from
118 WinSock.
Georg Brandl116aa622007-08-15 14:28:22 +0000119
Antoine Pitroucfad97b2011-01-25 17:24:57 +0000120.. attribute:: PIPE_BUF
Gregory P. Smithb970b862009-07-04 02:28:47 +0000121
Antoine Pitrouda7be3e2011-01-25 16:28:44 +0000122 The minimum number of bytes which can be written without blocking to a pipe
123 when the pipe has been reported as ready for writing by :func:`select`,
124 :func:`poll` or another interface in this module. This doesn't apply
125 to other kind of file-like objects such as sockets.
126
Amaury Forgeot d'Arcace31022009-07-09 22:44:11 +0000127 This value is guaranteed by POSIX to be at least 512. Availability: Unix.
Gregory P. Smithb970b862009-07-04 02:28:47 +0000128
Mark Dickinson574b1d62009-10-01 20:20:09 +0000129 .. versionadded:: 3.2
Gregory P. Smithb970b862009-07-04 02:28:47 +0000130
Georg Brandl116aa622007-08-15 14:28:22 +0000131
Jesus Cead8b9ae62011-11-14 19:07:41 +0100132.. _devpoll-objects:
133
134``/dev/poll`` Polling Objects
135----------------------------------------------
136
137 http://developers.sun.com/solaris/articles/using_devpoll.html
138 http://developers.sun.com/solaris/articles/polling_efficient.html
139
140Solaris and derivatives have ``/dev/poll``. While :c:func:`select` is
141O(highest file descriptor) and :c:func:`poll` is O(number of file
142descriptors), ``/dev/poll`` is O(active file descriptors).
143
144``/dev/poll`` behaviour is very close to the standard :c:func:`poll`
145object.
146
147
148.. method:: devpoll.register(fd[, eventmask])
149
150 Register a file descriptor with the polling object. Future calls to the
151 :meth:`poll` method will then check whether the file descriptor has any pending
152 I/O events. *fd* can be either an integer, or an object with a :meth:`fileno`
153 method that returns an integer. File objects implement :meth:`fileno`, so they
154 can also be used as the argument.
155
156 *eventmask* is an optional bitmask describing the type of events you want to
157 check for. The constants are the same that with :c:func:`poll`
158 object. The default value is a combination of the constants :const:`POLLIN`,
159 :const:`POLLPRI`, and :const:`POLLOUT`.
160
161 .. warning::
162
163 Registering a file descriptor that's already registered is not an
164 error, but the result is undefined. The appropiate action is to
165 unregister or modify it first. This is an important difference
166 compared with :c:func:`poll`.
167
168
169.. method:: devpoll.modify(fd[, eventmask])
170
171 This method does an :meth:`unregister` followed by a
172 :meth:`register`. It is (a bit) more efficient that doing the same
173 explicitly.
174
175
176.. method:: devpoll.unregister(fd)
177
178 Remove a file descriptor being tracked by a polling object. Just like the
179 :meth:`register` method, *fd* can be an integer or an object with a
180 :meth:`fileno` method that returns an integer.
181
182 Attempting to remove a file descriptor that was never registered is
183 safely ignored.
184
185
186.. method:: devpoll.poll([timeout])
187
188 Polls the set of registered file descriptors, and returns a possibly-empty list
189 containing ``(fd, event)`` 2-tuples for the descriptors that have events or
190 errors to report. *fd* is the file descriptor, and *event* is a bitmask with
191 bits set for the reported events for that descriptor --- :const:`POLLIN` for
192 waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
193 to, and so forth. An empty list indicates that the call timed out and no file
194 descriptors had any events to report. If *timeout* is given, it specifies the
195 length of time in milliseconds which the system will wait for events before
196 returning. If *timeout* is omitted, -1, or :const:`None`, the call will
197 block until there is an event for this poll object.
198
199
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000200.. _epoll-objects:
201
202Edge and Level Trigger Polling (epoll) Objects
203----------------------------------------------
204
205 http://linux.die.net/man/4/epoll
206
207 *eventmask*
208
209 +-----------------------+-----------------------------------------------+
210 | Constant | Meaning |
211 +=======================+===============================================+
212 | :const:`EPOLLIN` | Available for read |
213 +-----------------------+-----------------------------------------------+
214 | :const:`EPOLLOUT` | Available for write |
215 +-----------------------+-----------------------------------------------+
216 | :const:`EPOLLPRI` | Urgent data for read |
217 +-----------------------+-----------------------------------------------+
Christian Heimes5e696852008-04-09 08:37:03 +0000218 | :const:`EPOLLERR` | Error condition happened on the assoc. fd |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000219 +-----------------------+-----------------------------------------------+
Christian Heimes5e696852008-04-09 08:37:03 +0000220 | :const:`EPOLLHUP` | Hang up happened on the assoc. fd |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000221 +-----------------------+-----------------------------------------------+
222 | :const:`EPOLLET` | Set Edge Trigger behavior, the default is |
223 | | Level Trigger behavior |
224 +-----------------------+-----------------------------------------------+
225 | :const:`EPOLLONESHOT` | Set one-shot behavior. After one event is |
226 | | pulled out, the fd is internally disabled |
227 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000228 | :const:`EPOLLRDNORM` | Equivalent to :const:`EPOLLIN` |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000229 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000230 | :const:`EPOLLRDBAND` | Priority data band can be read. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000231 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000232 | :const:`EPOLLWRNORM` | Equivalent to :const:`EPOLLOUT` |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000233 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000234 | :const:`EPOLLWRBAND` | Priority data may be written. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000235 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000236 | :const:`EPOLLMSG` | Ignored. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000237 +-----------------------+-----------------------------------------------+
238
239
240.. method:: epoll.close()
241
242 Close the control file descriptor of the epoll object.
243
244
245.. method:: epoll.fileno()
246
247 Return the file descriptor number of the control fd.
248
249
250.. method:: epoll.fromfd(fd)
251
252 Create an epoll object from a given file descriptor.
253
254
255.. method:: epoll.register(fd[, eventmask])
256
257 Register a fd descriptor with the epoll object.
258
259
260.. method:: epoll.modify(fd, eventmask)
261
262 Modify a register file descriptor.
263
264
265.. method:: epoll.unregister(fd)
266
267 Remove a registered file descriptor from the epoll object.
268
269
270.. method:: epoll.poll([timeout=-1[, maxevents=-1]])
271
272 Wait for events. timeout in seconds (float)
273
274
Georg Brandl116aa622007-08-15 14:28:22 +0000275.. _poll-objects:
276
277Polling Objects
278---------------
279
Georg Brandl60203b42010-10-06 10:11:56 +0000280The :c:func:`poll` system call, supported on most Unix systems, provides better
Georg Brandl116aa622007-08-15 14:28:22 +0000281scalability for network servers that service many, many clients at the same
Georg Brandl60203b42010-10-06 10:11:56 +0000282time. :c:func:`poll` scales better because the system call only requires listing
283the file descriptors of interest, while :c:func:`select` builds a bitmap, turns
Georg Brandl116aa622007-08-15 14:28:22 +0000284on bits for the fds of interest, and then afterward the whole bitmap has to be
Georg Brandl60203b42010-10-06 10:11:56 +0000285linearly scanned again. :c:func:`select` is O(highest file descriptor), while
286:c:func:`poll` is O(number of file descriptors).
Georg Brandl116aa622007-08-15 14:28:22 +0000287
288
289.. method:: poll.register(fd[, eventmask])
290
291 Register a file descriptor with the polling object. Future calls to the
292 :meth:`poll` method will then check whether the file descriptor has any pending
293 I/O events. *fd* can be either an integer, or an object with a :meth:`fileno`
294 method that returns an integer. File objects implement :meth:`fileno`, so they
295 can also be used as the argument.
296
297 *eventmask* is an optional bitmask describing the type of events you want to
298 check for, and can be a combination of the constants :const:`POLLIN`,
299 :const:`POLLPRI`, and :const:`POLLOUT`, described in the table below. If not
300 specified, the default value used will check for all 3 types of events.
301
302 +-------------------+------------------------------------------+
303 | Constant | Meaning |
304 +===================+==========================================+
305 | :const:`POLLIN` | There is data to read |
306 +-------------------+------------------------------------------+
307 | :const:`POLLPRI` | There is urgent data to read |
308 +-------------------+------------------------------------------+
309 | :const:`POLLOUT` | Ready for output: writing will not block |
310 +-------------------+------------------------------------------+
311 | :const:`POLLERR` | Error condition of some sort |
312 +-------------------+------------------------------------------+
313 | :const:`POLLHUP` | Hung up |
314 +-------------------+------------------------------------------+
315 | :const:`POLLNVAL` | Invalid request: descriptor not open |
316 +-------------------+------------------------------------------+
317
318 Registering a file descriptor that's already registered is not an error, and has
319 the same effect as registering the descriptor exactly once.
320
321
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000322.. method:: poll.modify(fd, eventmask)
323
324 Modifies an already registered fd. This has the same effect as
Jean-Paul Calderone7f94f392010-07-18 16:13:27 +0000325 ``register(fd, eventmask)``. Attempting to modify a file descriptor
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000326 that was never registered causes an :exc:`IOError` exception with errno
327 :const:`ENOENT` to be raised.
328
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000329
Georg Brandl116aa622007-08-15 14:28:22 +0000330.. method:: poll.unregister(fd)
331
332 Remove a file descriptor being tracked by a polling object. Just like the
333 :meth:`register` method, *fd* can be an integer or an object with a
334 :meth:`fileno` method that returns an integer.
335
336 Attempting to remove a file descriptor that was never registered causes a
337 :exc:`KeyError` exception to be raised.
338
339
340.. method:: poll.poll([timeout])
341
342 Polls the set of registered file descriptors, and returns a possibly-empty list
343 containing ``(fd, event)`` 2-tuples for the descriptors that have events or
344 errors to report. *fd* is the file descriptor, and *event* is a bitmask with
345 bits set for the reported events for that descriptor --- :const:`POLLIN` for
346 waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
347 to, and so forth. An empty list indicates that the call timed out and no file
348 descriptors had any events to report. If *timeout* is given, it specifies the
349 length of time in milliseconds which the system will wait for events before
350 returning. If *timeout* is omitted, negative, or :const:`None`, the call will
351 block until there is an event for this poll object.
352
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000353
354.. _kqueue-objects:
355
356Kqueue Objects
357--------------
358
359.. method:: kqueue.close()
360
361 Close the control file descriptor of the kqueue object.
362
363
364.. method:: kqueue.fileno()
365
366 Return the file descriptor number of the control fd.
367
368
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000369.. method:: kqueue.fromfd(fd)
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000370
371 Create a kqueue object from a given file descriptor.
372
373
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000374.. method:: kqueue.control(changelist, max_events[, timeout=None]) -> eventlist
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000375
376 Low level interface to kevent
377
378 - changelist must be an iterable of kevent object or None
379 - max_events must be 0 or a positive integer
380 - timeout in seconds (floats possible)
381
382
383.. _kevent-objects:
384
385Kevent Objects
386--------------
387
Christian Heimesfe337bf2008-03-23 21:54:12 +0000388http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000389
Christian Heimesfe337bf2008-03-23 21:54:12 +0000390.. attribute:: kevent.ident
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000391
392 Value used to identify the event. The interpretation depends on the filter
393 but it's usually the file descriptor. In the constructor ident can either
394 be an int or an object with a fileno() function. kevent stores the integer
395 internally.
396
Christian Heimesfe337bf2008-03-23 21:54:12 +0000397.. attribute:: kevent.filter
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000398
Georg Brandl1b5ab452009-08-13 07:56:35 +0000399 Name of the kernel filter.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000400
401 +---------------------------+---------------------------------------------+
402 | Constant | Meaning |
403 +===========================+=============================================+
404 | :const:`KQ_FILTER_READ` | Takes a descriptor and returns whenever |
405 | | there is data available to read |
406 +---------------------------+---------------------------------------------+
407 | :const:`KQ_FILTER_WRITE` | Takes a descriptor and returns whenever |
Georg Brandl1b5ab452009-08-13 07:56:35 +0000408 | | there is data available to write |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000409 +---------------------------+---------------------------------------------+
410 | :const:`KQ_FILTER_AIO` | AIO requests |
411 +---------------------------+---------------------------------------------+
412 | :const:`KQ_FILTER_VNODE` | Returns when one or more of the requested |
413 | | events watched in *fflag* occurs |
414 +---------------------------+---------------------------------------------+
415 | :const:`KQ_FILTER_PROC` | Watch for events on a process id |
416 +---------------------------+---------------------------------------------+
417 | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device |
418 | | [not available on Mac OS X] |
419 +---------------------------+---------------------------------------------+
420 | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is |
421 | | delivered to the process |
422 +---------------------------+---------------------------------------------+
423 | :const:`KQ_FILTER_TIMER` | Establishes an arbitrary timer |
424 +---------------------------+---------------------------------------------+
425
Christian Heimesfe337bf2008-03-23 21:54:12 +0000426.. attribute:: kevent.flags
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000427
Georg Brandl1b5ab452009-08-13 07:56:35 +0000428 Filter action.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000429
430 +---------------------------+---------------------------------------------+
431 | Constant | Meaning |
432 +===========================+=============================================+
433 | :const:`KQ_EV_ADD` | Adds or modifies an event |
434 +---------------------------+---------------------------------------------+
435 | :const:`KQ_EV_DELETE` | Removes an event from the queue |
436 +---------------------------+---------------------------------------------+
437 | :const:`KQ_EV_ENABLE` | Permitscontrol() to returns the event |
438 +---------------------------+---------------------------------------------+
439 | :const:`KQ_EV_DISABLE` | Disablesevent |
440 +---------------------------+---------------------------------------------+
Georg Brandl2ee470f2008-07-16 12:55:28 +0000441 | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000442 +---------------------------+---------------------------------------------+
443 | :const:`KQ_EV_CLEAR` | Reset the state after an event is retrieved |
444 +---------------------------+---------------------------------------------+
445 | :const:`KQ_EV_SYSFLAGS` | internal event |
446 +---------------------------+---------------------------------------------+
447 | :const:`KQ_EV_FLAG1` | internal event |
448 +---------------------------+---------------------------------------------+
449 | :const:`KQ_EV_EOF` | Filter specific EOF condition |
450 +---------------------------+---------------------------------------------+
451 | :const:`KQ_EV_ERROR` | See return values |
452 +---------------------------+---------------------------------------------+
453
454
Christian Heimesfe337bf2008-03-23 21:54:12 +0000455.. attribute:: kevent.fflags
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000456
Georg Brandl1b5ab452009-08-13 07:56:35 +0000457 Filter specific flags.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000458
Georg Brandl1b5ab452009-08-13 07:56:35 +0000459 :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000460
461 +----------------------------+--------------------------------------------+
462 | Constant | Meaning |
463 +============================+============================================+
464 | :const:`KQ_NOTE_LOWAT` | low water mark of a socket buffer |
465 +----------------------------+--------------------------------------------+
466
Georg Brandl1b5ab452009-08-13 07:56:35 +0000467 :const:`KQ_FILTER_VNODE` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000468
469 +----------------------------+--------------------------------------------+
470 | Constant | Meaning |
471 +============================+============================================+
472 | :const:`KQ_NOTE_DELETE` | *unlink()* was called |
473 +----------------------------+--------------------------------------------+
Georg Brandl2ee470f2008-07-16 12:55:28 +0000474 | :const:`KQ_NOTE_WRITE` | a write occurred |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000475 +----------------------------+--------------------------------------------+
476 | :const:`KQ_NOTE_EXTEND` | the file was extended |
477 +----------------------------+--------------------------------------------+
478 | :const:`KQ_NOTE_ATTRIB` | an attribute was changed |
479 +----------------------------+--------------------------------------------+
480 | :const:`KQ_NOTE_LINK` | the link count has changed |
481 +----------------------------+--------------------------------------------+
482 | :const:`KQ_NOTE_RENAME` | the file was renamed |
483 +----------------------------+--------------------------------------------+
484 | :const:`KQ_NOTE_REVOKE` | access to the file was revoked |
485 +----------------------------+--------------------------------------------+
486
Georg Brandl1b5ab452009-08-13 07:56:35 +0000487 :const:`KQ_FILTER_PROC` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000488
489 +----------------------------+--------------------------------------------+
490 | Constant | Meaning |
491 +============================+============================================+
492 | :const:`KQ_NOTE_EXIT` | the process has exited |
493 +----------------------------+--------------------------------------------+
494 | :const:`KQ_NOTE_FORK` | the process has called *fork()* |
495 +----------------------------+--------------------------------------------+
496 | :const:`KQ_NOTE_EXEC` | the process has executed a new process |
497 +----------------------------+--------------------------------------------+
498 | :const:`KQ_NOTE_PCTRLMASK` | internal filter flag |
499 +----------------------------+--------------------------------------------+
500 | :const:`KQ_NOTE_PDATAMASK` | internal filter flag |
501 +----------------------------+--------------------------------------------+
502 | :const:`KQ_NOTE_TRACK` | follow a process across *fork()* |
503 +----------------------------+--------------------------------------------+
504 | :const:`KQ_NOTE_CHILD` | returned on the child process for |
505 | | *NOTE_TRACK* |
506 +----------------------------+--------------------------------------------+
507 | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child |
508 +----------------------------+--------------------------------------------+
509
Georg Brandl1b5ab452009-08-13 07:56:35 +0000510 :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X):
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000511
512 +----------------------------+--------------------------------------------+
513 | Constant | Meaning |
514 +============================+============================================+
515 | :const:`KQ_NOTE_LINKUP` | link is up |
516 +----------------------------+--------------------------------------------+
517 | :const:`KQ_NOTE_LINKDOWN` | link is down |
518 +----------------------------+--------------------------------------------+
519 | :const:`KQ_NOTE_LINKINV` | link state is invalid |
520 +----------------------------+--------------------------------------------+
521
522
Christian Heimesfe337bf2008-03-23 21:54:12 +0000523.. attribute:: kevent.data
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000524
Georg Brandl1b5ab452009-08-13 07:56:35 +0000525 Filter specific data.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000526
527
Christian Heimesfe337bf2008-03-23 21:54:12 +0000528.. attribute:: kevent.udata
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000529
Georg Brandl1b5ab452009-08-13 07:56:35 +0000530 User defined value.