blob: 72fba732e42fd28f9daef44a201ad0dc72b0e0ef [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
Georg Brandl18244152009-09-02 20:34:52 +000042.. function:: epoll(sizehint=-1)
Christian Heimes4fbc72b2008-03-22 00:47:35 +000043
Christian Heimesfe337bf2008-03-23 21:54:12 +000044 (Only supported on Linux 2.5.44 and newer.) Returns an edge polling object,
45 which can be used as Edge or Level Triggered interface for I/O events; see
46 section :ref:`epoll-objects` below for the methods supported by epolling
47 objects.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000048
Christian Heimes4fbc72b2008-03-22 00:47:35 +000049
Georg Brandl116aa622007-08-15 14:28:22 +000050.. function:: poll()
51
52 (Not supported by all operating systems.) Returns a polling object, which
53 supports registering and unregistering file descriptors, and then polling them
54 for I/O events; see section :ref:`poll-objects` below for the methods supported
55 by polling objects.
56
57
Christian Heimesfe337bf2008-03-23 21:54:12 +000058.. function:: kqueue()
Christian Heimes4fbc72b2008-03-22 00:47:35 +000059
Georg Brandle767e042010-07-14 08:00:22 +000060 (Only supported on BSD.) Returns a kernel queue object; see section
Christian Heimesfe337bf2008-03-23 21:54:12 +000061 :ref:`kqueue-objects` below for the methods supported by kqueue objects.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000062
Christian Heimes4fbc72b2008-03-22 00:47:35 +000063
Benjamin Peterson1baf4652009-12-31 03:11:23 +000064.. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0)
Christian Heimes4fbc72b2008-03-22 00:47:35 +000065
Georg Brandle767e042010-07-14 08:00:22 +000066 (Only supported on BSD.) Returns a kernel event object; see section
67 :ref:`kevent-objects` below for the methods supported by kevent objects.
Christian Heimes4fbc72b2008-03-22 00:47:35 +000068
Christian Heimes4fbc72b2008-03-22 00:47:35 +000069
Georg Brandl734e2682008-08-12 08:18:18 +000070.. function:: select(rlist, wlist, xlist[, timeout])
Georg Brandl116aa622007-08-15 14:28:22 +000071
Georg Brandl60203b42010-10-06 10:11:56 +000072 This is a straightforward interface to the Unix :c:func:`select` system call.
Georg Brandl116aa622007-08-15 14:28:22 +000073 The first three arguments are sequences of 'waitable objects': either
74 integers representing file descriptors or objects with a parameterless method
Georg Brandl734e2682008-08-12 08:18:18 +000075 named :meth:`fileno` returning such an integer:
76
77 * *rlist*: wait until ready for reading
78 * *wlist*: wait until ready for writing
79 * *xlist*: wait for an "exceptional condition" (see the manual page for what
80 your system considers such a condition)
81
82 Empty sequences are allowed, but acceptance of three empty sequences is
83 platform-dependent. (It is known to work on Unix but not on Windows.) The
84 optional *timeout* argument specifies a time-out as a floating point number
85 in seconds. When the *timeout* argument is omitted the function blocks until
86 at least one file descriptor is ready. A time-out value of zero specifies a
87 poll and never blocks.
Georg Brandl116aa622007-08-15 14:28:22 +000088
89 The return value is a triple of lists of objects that are ready: subsets of the
90 first three arguments. When the time-out is reached without a file descriptor
91 becoming ready, three empty lists are returned.
92
93 .. index::
94 single: socket() (in module socket)
95 single: popen() (in module os)
96
Antoine Pitrou11cb9612010-09-15 11:11:28 +000097 Among the acceptable object types in the sequences are Python :term:`file
98 objects <file object>` (e.g. ``sys.stdin``, or objects returned by
99 :func:`open` or :func:`os.popen`), socket objects returned by
100 :func:`socket.socket`. You may also define a :dfn:`wrapper` class yourself,
101 as long as it has an appropriate :meth:`fileno` method (that really returns
102 a file descriptor, not just a random integer).
Georg Brandl116aa622007-08-15 14:28:22 +0000103
Georg Brandl116aa622007-08-15 14:28:22 +0000104 .. note::
105
106 .. index:: single: WinSock
107
Georg Brandl734e2682008-08-12 08:18:18 +0000108 File objects on Windows are not acceptable, but sockets are. On Windows,
Georg Brandl60203b42010-10-06 10:11:56 +0000109 the underlying :c:func:`select` function is provided by the WinSock
Georg Brandl734e2682008-08-12 08:18:18 +0000110 library, and does not handle file descriptors that don't originate from
111 WinSock.
Georg Brandl116aa622007-08-15 14:28:22 +0000112
Antoine Pitroucfad97b2011-01-25 17:24:57 +0000113.. attribute:: PIPE_BUF
Gregory P. Smithb970b862009-07-04 02:28:47 +0000114
Antoine Pitrouda7be3e2011-01-25 16:28:44 +0000115 The minimum number of bytes which can be written without blocking to a pipe
116 when the pipe has been reported as ready for writing by :func:`select`,
117 :func:`poll` or another interface in this module. This doesn't apply
118 to other kind of file-like objects such as sockets.
119
Amaury Forgeot d'Arcace31022009-07-09 22:44:11 +0000120 This value is guaranteed by POSIX to be at least 512. Availability: Unix.
Gregory P. Smithb970b862009-07-04 02:28:47 +0000121
Mark Dickinson574b1d62009-10-01 20:20:09 +0000122 .. versionadded:: 3.2
Gregory P. Smithb970b862009-07-04 02:28:47 +0000123
Georg Brandl116aa622007-08-15 14:28:22 +0000124
Jesus Cead8b9ae62011-11-14 19:07:41 +0100125.. _devpoll-objects:
126
127``/dev/poll`` Polling Objects
128----------------------------------------------
129
130 http://developers.sun.com/solaris/articles/using_devpoll.html
131 http://developers.sun.com/solaris/articles/polling_efficient.html
132
133Solaris and derivatives have ``/dev/poll``. While :c:func:`select` is
134O(highest file descriptor) and :c:func:`poll` is O(number of file
135descriptors), ``/dev/poll`` is O(active file descriptors).
136
137``/dev/poll`` behaviour is very close to the standard :c:func:`poll`
138object.
139
140
141.. method:: devpoll.register(fd[, eventmask])
142
143 Register a file descriptor with the polling object. Future calls to the
144 :meth:`poll` method will then check whether the file descriptor has any pending
145 I/O events. *fd* can be either an integer, or an object with a :meth:`fileno`
146 method that returns an integer. File objects implement :meth:`fileno`, so they
147 can also be used as the argument.
148
149 *eventmask* is an optional bitmask describing the type of events you want to
150 check for. The constants are the same that with :c:func:`poll`
151 object. The default value is a combination of the constants :const:`POLLIN`,
152 :const:`POLLPRI`, and :const:`POLLOUT`.
153
154 .. warning::
155
156 Registering a file descriptor that's already registered is not an
157 error, but the result is undefined. The appropiate action is to
158 unregister or modify it first. This is an important difference
159 compared with :c:func:`poll`.
160
161
162.. method:: devpoll.modify(fd[, eventmask])
163
164 This method does an :meth:`unregister` followed by a
165 :meth:`register`. It is (a bit) more efficient that doing the same
166 explicitly.
167
168
169.. method:: devpoll.unregister(fd)
170
171 Remove a file descriptor being tracked by a polling object. Just like the
172 :meth:`register` method, *fd* can be an integer or an object with a
173 :meth:`fileno` method that returns an integer.
174
175 Attempting to remove a file descriptor that was never registered is
176 safely ignored.
177
178
179.. method:: devpoll.poll([timeout])
180
181 Polls the set of registered file descriptors, and returns a possibly-empty list
182 containing ``(fd, event)`` 2-tuples for the descriptors that have events or
183 errors to report. *fd* is the file descriptor, and *event* is a bitmask with
184 bits set for the reported events for that descriptor --- :const:`POLLIN` for
185 waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
186 to, and so forth. An empty list indicates that the call timed out and no file
187 descriptors had any events to report. If *timeout* is given, it specifies the
188 length of time in milliseconds which the system will wait for events before
189 returning. If *timeout* is omitted, -1, or :const:`None`, the call will
190 block until there is an event for this poll object.
191
192
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000193.. _epoll-objects:
194
195Edge and Level Trigger Polling (epoll) Objects
196----------------------------------------------
197
198 http://linux.die.net/man/4/epoll
199
200 *eventmask*
201
202 +-----------------------+-----------------------------------------------+
203 | Constant | Meaning |
204 +=======================+===============================================+
205 | :const:`EPOLLIN` | Available for read |
206 +-----------------------+-----------------------------------------------+
207 | :const:`EPOLLOUT` | Available for write |
208 +-----------------------+-----------------------------------------------+
209 | :const:`EPOLLPRI` | Urgent data for read |
210 +-----------------------+-----------------------------------------------+
Christian Heimes5e696852008-04-09 08:37:03 +0000211 | :const:`EPOLLERR` | Error condition happened on the assoc. fd |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000212 +-----------------------+-----------------------------------------------+
Christian Heimes5e696852008-04-09 08:37:03 +0000213 | :const:`EPOLLHUP` | Hang up happened on the assoc. fd |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000214 +-----------------------+-----------------------------------------------+
215 | :const:`EPOLLET` | Set Edge Trigger behavior, the default is |
216 | | Level Trigger behavior |
217 +-----------------------+-----------------------------------------------+
218 | :const:`EPOLLONESHOT` | Set one-shot behavior. After one event is |
219 | | pulled out, the fd is internally disabled |
220 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000221 | :const:`EPOLLRDNORM` | Equivalent to :const:`EPOLLIN` |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000222 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000223 | :const:`EPOLLRDBAND` | Priority data band can be read. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000224 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000225 | :const:`EPOLLWRNORM` | Equivalent to :const:`EPOLLOUT` |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000226 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000227 | :const:`EPOLLWRBAND` | Priority data may be written. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000228 +-----------------------+-----------------------------------------------+
Jean-Paul Calderone7f54dce2010-07-18 16:30:31 +0000229 | :const:`EPOLLMSG` | Ignored. |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000230 +-----------------------+-----------------------------------------------+
231
232
233.. method:: epoll.close()
234
235 Close the control file descriptor of the epoll object.
236
237
238.. method:: epoll.fileno()
239
240 Return the file descriptor number of the control fd.
241
242
243.. method:: epoll.fromfd(fd)
244
245 Create an epoll object from a given file descriptor.
246
247
248.. method:: epoll.register(fd[, eventmask])
249
250 Register a fd descriptor with the epoll object.
251
252
253.. method:: epoll.modify(fd, eventmask)
254
255 Modify a register file descriptor.
256
257
258.. method:: epoll.unregister(fd)
259
260 Remove a registered file descriptor from the epoll object.
261
262
263.. method:: epoll.poll([timeout=-1[, maxevents=-1]])
264
265 Wait for events. timeout in seconds (float)
266
267
Georg Brandl116aa622007-08-15 14:28:22 +0000268.. _poll-objects:
269
270Polling Objects
271---------------
272
Georg Brandl60203b42010-10-06 10:11:56 +0000273The :c:func:`poll` system call, supported on most Unix systems, provides better
Georg Brandl116aa622007-08-15 14:28:22 +0000274scalability for network servers that service many, many clients at the same
Georg Brandl60203b42010-10-06 10:11:56 +0000275time. :c:func:`poll` scales better because the system call only requires listing
276the file descriptors of interest, while :c:func:`select` builds a bitmap, turns
Georg Brandl116aa622007-08-15 14:28:22 +0000277on bits for the fds of interest, and then afterward the whole bitmap has to be
Georg Brandl60203b42010-10-06 10:11:56 +0000278linearly scanned again. :c:func:`select` is O(highest file descriptor), while
279:c:func:`poll` is O(number of file descriptors).
Georg Brandl116aa622007-08-15 14:28:22 +0000280
281
282.. method:: poll.register(fd[, eventmask])
283
284 Register a file descriptor with the polling object. Future calls to the
285 :meth:`poll` method will then check whether the file descriptor has any pending
286 I/O events. *fd* can be either an integer, or an object with a :meth:`fileno`
287 method that returns an integer. File objects implement :meth:`fileno`, so they
288 can also be used as the argument.
289
290 *eventmask* is an optional bitmask describing the type of events you want to
291 check for, and can be a combination of the constants :const:`POLLIN`,
292 :const:`POLLPRI`, and :const:`POLLOUT`, described in the table below. If not
293 specified, the default value used will check for all 3 types of events.
294
295 +-------------------+------------------------------------------+
296 | Constant | Meaning |
297 +===================+==========================================+
298 | :const:`POLLIN` | There is data to read |
299 +-------------------+------------------------------------------+
300 | :const:`POLLPRI` | There is urgent data to read |
301 +-------------------+------------------------------------------+
302 | :const:`POLLOUT` | Ready for output: writing will not block |
303 +-------------------+------------------------------------------+
304 | :const:`POLLERR` | Error condition of some sort |
305 +-------------------+------------------------------------------+
306 | :const:`POLLHUP` | Hung up |
307 +-------------------+------------------------------------------+
308 | :const:`POLLNVAL` | Invalid request: descriptor not open |
309 +-------------------+------------------------------------------+
310
311 Registering a file descriptor that's already registered is not an error, and has
312 the same effect as registering the descriptor exactly once.
313
314
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000315.. method:: poll.modify(fd, eventmask)
316
317 Modifies an already registered fd. This has the same effect as
Jean-Paul Calderone7f94f392010-07-18 16:13:27 +0000318 ``register(fd, eventmask)``. Attempting to modify a file descriptor
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000319 that was never registered causes an :exc:`IOError` exception with errno
320 :const:`ENOENT` to be raised.
321
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000322
Georg Brandl116aa622007-08-15 14:28:22 +0000323.. method:: poll.unregister(fd)
324
325 Remove a file descriptor being tracked by a polling object. Just like the
326 :meth:`register` method, *fd* can be an integer or an object with a
327 :meth:`fileno` method that returns an integer.
328
329 Attempting to remove a file descriptor that was never registered causes a
330 :exc:`KeyError` exception to be raised.
331
332
333.. method:: poll.poll([timeout])
334
335 Polls the set of registered file descriptors, and returns a possibly-empty list
336 containing ``(fd, event)`` 2-tuples for the descriptors that have events or
337 errors to report. *fd* is the file descriptor, and *event* is a bitmask with
338 bits set for the reported events for that descriptor --- :const:`POLLIN` for
339 waiting input, :const:`POLLOUT` to indicate that the descriptor can be written
340 to, and so forth. An empty list indicates that the call timed out and no file
341 descriptors had any events to report. If *timeout* is given, it specifies the
342 length of time in milliseconds which the system will wait for events before
343 returning. If *timeout* is omitted, negative, or :const:`None`, the call will
344 block until there is an event for this poll object.
345
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000346
347.. _kqueue-objects:
348
349Kqueue Objects
350--------------
351
352.. method:: kqueue.close()
353
354 Close the control file descriptor of the kqueue object.
355
356
357.. method:: kqueue.fileno()
358
359 Return the file descriptor number of the control fd.
360
361
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000362.. method:: kqueue.fromfd(fd)
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000363
364 Create a kqueue object from a given file descriptor.
365
366
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000367.. method:: kqueue.control(changelist, max_events[, timeout=None]) -> eventlist
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000368
369 Low level interface to kevent
370
371 - changelist must be an iterable of kevent object or None
372 - max_events must be 0 or a positive integer
373 - timeout in seconds (floats possible)
374
375
376.. _kevent-objects:
377
378Kevent Objects
379--------------
380
Christian Heimesfe337bf2008-03-23 21:54:12 +0000381http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000382
Christian Heimesfe337bf2008-03-23 21:54:12 +0000383.. attribute:: kevent.ident
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000384
385 Value used to identify the event. The interpretation depends on the filter
386 but it's usually the file descriptor. In the constructor ident can either
387 be an int or an object with a fileno() function. kevent stores the integer
388 internally.
389
Christian Heimesfe337bf2008-03-23 21:54:12 +0000390.. attribute:: kevent.filter
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000391
Georg Brandl1b5ab452009-08-13 07:56:35 +0000392 Name of the kernel filter.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000393
394 +---------------------------+---------------------------------------------+
395 | Constant | Meaning |
396 +===========================+=============================================+
397 | :const:`KQ_FILTER_READ` | Takes a descriptor and returns whenever |
398 | | there is data available to read |
399 +---------------------------+---------------------------------------------+
400 | :const:`KQ_FILTER_WRITE` | Takes a descriptor and returns whenever |
Georg Brandl1b5ab452009-08-13 07:56:35 +0000401 | | there is data available to write |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000402 +---------------------------+---------------------------------------------+
403 | :const:`KQ_FILTER_AIO` | AIO requests |
404 +---------------------------+---------------------------------------------+
405 | :const:`KQ_FILTER_VNODE` | Returns when one or more of the requested |
406 | | events watched in *fflag* occurs |
407 +---------------------------+---------------------------------------------+
408 | :const:`KQ_FILTER_PROC` | Watch for events on a process id |
409 +---------------------------+---------------------------------------------+
410 | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device |
411 | | [not available on Mac OS X] |
412 +---------------------------+---------------------------------------------+
413 | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is |
414 | | delivered to the process |
415 +---------------------------+---------------------------------------------+
416 | :const:`KQ_FILTER_TIMER` | Establishes an arbitrary timer |
417 +---------------------------+---------------------------------------------+
418
Christian Heimesfe337bf2008-03-23 21:54:12 +0000419.. attribute:: kevent.flags
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000420
Georg Brandl1b5ab452009-08-13 07:56:35 +0000421 Filter action.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000422
423 +---------------------------+---------------------------------------------+
424 | Constant | Meaning |
425 +===========================+=============================================+
426 | :const:`KQ_EV_ADD` | Adds or modifies an event |
427 +---------------------------+---------------------------------------------+
428 | :const:`KQ_EV_DELETE` | Removes an event from the queue |
429 +---------------------------+---------------------------------------------+
430 | :const:`KQ_EV_ENABLE` | Permitscontrol() to returns the event |
431 +---------------------------+---------------------------------------------+
432 | :const:`KQ_EV_DISABLE` | Disablesevent |
433 +---------------------------+---------------------------------------------+
Georg Brandl2ee470f2008-07-16 12:55:28 +0000434 | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000435 +---------------------------+---------------------------------------------+
436 | :const:`KQ_EV_CLEAR` | Reset the state after an event is retrieved |
437 +---------------------------+---------------------------------------------+
438 | :const:`KQ_EV_SYSFLAGS` | internal event |
439 +---------------------------+---------------------------------------------+
440 | :const:`KQ_EV_FLAG1` | internal event |
441 +---------------------------+---------------------------------------------+
442 | :const:`KQ_EV_EOF` | Filter specific EOF condition |
443 +---------------------------+---------------------------------------------+
444 | :const:`KQ_EV_ERROR` | See return values |
445 +---------------------------+---------------------------------------------+
446
447
Christian Heimesfe337bf2008-03-23 21:54:12 +0000448.. attribute:: kevent.fflags
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000449
Georg Brandl1b5ab452009-08-13 07:56:35 +0000450 Filter specific flags.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000451
Georg Brandl1b5ab452009-08-13 07:56:35 +0000452 :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000453
454 +----------------------------+--------------------------------------------+
455 | Constant | Meaning |
456 +============================+============================================+
457 | :const:`KQ_NOTE_LOWAT` | low water mark of a socket buffer |
458 +----------------------------+--------------------------------------------+
459
Georg Brandl1b5ab452009-08-13 07:56:35 +0000460 :const:`KQ_FILTER_VNODE` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000461
462 +----------------------------+--------------------------------------------+
463 | Constant | Meaning |
464 +============================+============================================+
465 | :const:`KQ_NOTE_DELETE` | *unlink()* was called |
466 +----------------------------+--------------------------------------------+
Georg Brandl2ee470f2008-07-16 12:55:28 +0000467 | :const:`KQ_NOTE_WRITE` | a write occurred |
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000468 +----------------------------+--------------------------------------------+
469 | :const:`KQ_NOTE_EXTEND` | the file was extended |
470 +----------------------------+--------------------------------------------+
471 | :const:`KQ_NOTE_ATTRIB` | an attribute was changed |
472 +----------------------------+--------------------------------------------+
473 | :const:`KQ_NOTE_LINK` | the link count has changed |
474 +----------------------------+--------------------------------------------+
475 | :const:`KQ_NOTE_RENAME` | the file was renamed |
476 +----------------------------+--------------------------------------------+
477 | :const:`KQ_NOTE_REVOKE` | access to the file was revoked |
478 +----------------------------+--------------------------------------------+
479
Georg Brandl1b5ab452009-08-13 07:56:35 +0000480 :const:`KQ_FILTER_PROC` filter flags:
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000481
482 +----------------------------+--------------------------------------------+
483 | Constant | Meaning |
484 +============================+============================================+
485 | :const:`KQ_NOTE_EXIT` | the process has exited |
486 +----------------------------+--------------------------------------------+
487 | :const:`KQ_NOTE_FORK` | the process has called *fork()* |
488 +----------------------------+--------------------------------------------+
489 | :const:`KQ_NOTE_EXEC` | the process has executed a new process |
490 +----------------------------+--------------------------------------------+
491 | :const:`KQ_NOTE_PCTRLMASK` | internal filter flag |
492 +----------------------------+--------------------------------------------+
493 | :const:`KQ_NOTE_PDATAMASK` | internal filter flag |
494 +----------------------------+--------------------------------------------+
495 | :const:`KQ_NOTE_TRACK` | follow a process across *fork()* |
496 +----------------------------+--------------------------------------------+
497 | :const:`KQ_NOTE_CHILD` | returned on the child process for |
498 | | *NOTE_TRACK* |
499 +----------------------------+--------------------------------------------+
500 | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child |
501 +----------------------------+--------------------------------------------+
502
Georg Brandl1b5ab452009-08-13 07:56:35 +0000503 :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X):
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000504
505 +----------------------------+--------------------------------------------+
506 | Constant | Meaning |
507 +============================+============================================+
508 | :const:`KQ_NOTE_LINKUP` | link is up |
509 +----------------------------+--------------------------------------------+
510 | :const:`KQ_NOTE_LINKDOWN` | link is down |
511 +----------------------------+--------------------------------------------+
512 | :const:`KQ_NOTE_LINKINV` | link state is invalid |
513 +----------------------------+--------------------------------------------+
514
515
Christian Heimesfe337bf2008-03-23 21:54:12 +0000516.. attribute:: kevent.data
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000517
Georg Brandl1b5ab452009-08-13 07:56:35 +0000518 Filter specific data.
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000519
520
Christian Heimesfe337bf2008-03-23 21:54:12 +0000521.. attribute:: kevent.udata
Christian Heimes4fbc72b2008-03-22 00:47:35 +0000522
Georg Brandl1b5ab452009-08-13 07:56:35 +0000523 User defined value.