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