Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`select` --- Waiting for I/O completion |
| 2 | ============================================ |
| 3 | |
| 4 | .. module:: select |
| 5 | :synopsis: Wait for I/O completion on multiple streams. |
| 6 | |
| 7 | |
| 8 | This module provides access to the :cfunc:`select` and :cfunc:`poll` functions |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 9 | available in most operating systems, :cfunc:`epoll` available on Linux 2.5+ and |
| 10 | :cfunc:`kqueue` available on most BSD. |
| 11 | Note that on Windows, it only works for sockets; on other operating systems, |
| 12 | it also works for other file types (in particular, on Unix, it works on pipes). |
| 13 | It cannot be used on regular files to determine whether a file has grown since |
| 14 | it was last read. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 15 | |
| 16 | The module defines the following: |
| 17 | |
| 18 | |
| 19 | .. exception:: error |
| 20 | |
| 21 | The exception raised when an error occurs. The accompanying value is a pair |
| 22 | containing the numeric error code from :cdata:`errno` and the corresponding |
| 23 | string, as would be printed by the C function :cfunc:`perror`. |
| 24 | |
| 25 | |
Georg Brandl | 1824415 | 2009-09-02 20:34:52 +0000 | [diff] [blame] | 26 | .. function:: epoll(sizehint=-1) |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 27 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 28 | (Only supported on Linux 2.5.44 and newer.) Returns an edge polling object, |
| 29 | which can be used as Edge or Level Triggered interface for I/O events; see |
| 30 | section :ref:`epoll-objects` below for the methods supported by epolling |
| 31 | objects. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 32 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 33 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 34 | .. function:: poll() |
| 35 | |
| 36 | (Not supported by all operating systems.) Returns a polling object, which |
| 37 | supports registering and unregistering file descriptors, and then polling them |
| 38 | for I/O events; see section :ref:`poll-objects` below for the methods supported |
| 39 | by polling objects. |
| 40 | |
| 41 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 42 | .. function:: kqueue() |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 43 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 44 | (Only supported on BSD.) Returns a kernel queue object object; see section |
| 45 | :ref:`kqueue-objects` below for the methods supported by kqueue objects. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 46 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 47 | |
Benjamin Peterson | 1baf465 | 2009-12-31 03:11:23 +0000 | [diff] [blame^] | 48 | .. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0) |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 49 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 50 | (Only supported on BSD.) Returns a kernel event object object; see section |
| 51 | :ref:`kevent-objects` below for the methods supported by kqueue objects. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 52 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 53 | |
Georg Brandl | 734e268 | 2008-08-12 08:18:18 +0000 | [diff] [blame] | 54 | .. function:: select(rlist, wlist, xlist[, timeout]) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 55 | |
| 56 | This is a straightforward interface to the Unix :cfunc:`select` system call. |
| 57 | The first three arguments are sequences of 'waitable objects': either |
| 58 | integers representing file descriptors or objects with a parameterless method |
Georg Brandl | 734e268 | 2008-08-12 08:18:18 +0000 | [diff] [blame] | 59 | named :meth:`fileno` returning such an integer: |
| 60 | |
| 61 | * *rlist*: wait until ready for reading |
| 62 | * *wlist*: wait until ready for writing |
| 63 | * *xlist*: wait for an "exceptional condition" (see the manual page for what |
| 64 | your system considers such a condition) |
| 65 | |
| 66 | Empty sequences are allowed, but acceptance of three empty sequences is |
| 67 | platform-dependent. (It is known to work on Unix but not on Windows.) The |
| 68 | optional *timeout* argument specifies a time-out as a floating point number |
| 69 | in seconds. When the *timeout* argument is omitted the function blocks until |
| 70 | at least one file descriptor is ready. A time-out value of zero specifies a |
| 71 | poll and never blocks. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 72 | |
| 73 | The return value is a triple of lists of objects that are ready: subsets of the |
| 74 | first three arguments. When the time-out is reached without a file descriptor |
| 75 | becoming ready, three empty lists are returned. |
| 76 | |
| 77 | .. index:: |
| 78 | single: socket() (in module socket) |
| 79 | single: popen() (in module os) |
| 80 | |
| 81 | Among the acceptable object types in the sequences are Python file objects (e.g. |
| 82 | ``sys.stdin``, or objects returned by :func:`open` or :func:`os.popen`), socket |
| 83 | objects returned by :func:`socket.socket`. You may also define a :dfn:`wrapper` |
| 84 | class yourself, as long as it has an appropriate :meth:`fileno` method (that |
| 85 | really returns a file descriptor, not just a random integer). |
| 86 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 87 | .. note:: |
| 88 | |
| 89 | .. index:: single: WinSock |
| 90 | |
Georg Brandl | 734e268 | 2008-08-12 08:18:18 +0000 | [diff] [blame] | 91 | File objects on Windows are not acceptable, but sockets are. On Windows, |
| 92 | the underlying :cfunc:`select` function is provided by the WinSock |
| 93 | library, and does not handle file descriptors that don't originate from |
| 94 | WinSock. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 95 | |
Gregory P. Smith | b970b86 | 2009-07-04 02:28:47 +0000 | [diff] [blame] | 96 | .. attribute:: select.PIPE_BUF |
| 97 | |
| 98 | Files reported as ready for writing by :func:`select`, :func:`poll` or |
| 99 | similar interfaces in this module are guaranteed to not block on a write |
| 100 | of up to :const:`PIPE_BUF` bytes. |
Amaury Forgeot d'Arc | ace3102 | 2009-07-09 22:44:11 +0000 | [diff] [blame] | 101 | This value is guaranteed by POSIX to be at least 512. Availability: Unix. |
Gregory P. Smith | b970b86 | 2009-07-04 02:28:47 +0000 | [diff] [blame] | 102 | |
Mark Dickinson | 574b1d6 | 2009-10-01 20:20:09 +0000 | [diff] [blame] | 103 | .. versionadded:: 3.2 |
Gregory P. Smith | b970b86 | 2009-07-04 02:28:47 +0000 | [diff] [blame] | 104 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 105 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 106 | .. _epoll-objects: |
| 107 | |
| 108 | Edge and Level Trigger Polling (epoll) Objects |
| 109 | ---------------------------------------------- |
| 110 | |
| 111 | http://linux.die.net/man/4/epoll |
| 112 | |
| 113 | *eventmask* |
| 114 | |
| 115 | +-----------------------+-----------------------------------------------+ |
| 116 | | Constant | Meaning | |
| 117 | +=======================+===============================================+ |
| 118 | | :const:`EPOLLIN` | Available for read | |
| 119 | +-----------------------+-----------------------------------------------+ |
| 120 | | :const:`EPOLLOUT` | Available for write | |
| 121 | +-----------------------+-----------------------------------------------+ |
| 122 | | :const:`EPOLLPRI` | Urgent data for read | |
| 123 | +-----------------------+-----------------------------------------------+ |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 124 | | :const:`EPOLLERR` | Error condition happened on the assoc. fd | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 125 | +-----------------------+-----------------------------------------------+ |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 126 | | :const:`EPOLLHUP` | Hang up happened on the assoc. fd | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 127 | +-----------------------+-----------------------------------------------+ |
| 128 | | :const:`EPOLLET` | Set Edge Trigger behavior, the default is | |
| 129 | | | Level Trigger behavior | |
| 130 | +-----------------------+-----------------------------------------------+ |
| 131 | | :const:`EPOLLONESHOT` | Set one-shot behavior. After one event is | |
| 132 | | | pulled out, the fd is internally disabled | |
| 133 | +-----------------------+-----------------------------------------------+ |
| 134 | | :const:`EPOLLRDNORM` | ??? | |
| 135 | +-----------------------+-----------------------------------------------+ |
| 136 | | :const:`EPOLLRDBAND` | ??? | |
| 137 | +-----------------------+-----------------------------------------------+ |
| 138 | | :const:`EPOLLWRNORM` | ??? | |
| 139 | +-----------------------+-----------------------------------------------+ |
| 140 | | :const:`EPOLLWRBAND` | ??? | |
| 141 | +-----------------------+-----------------------------------------------+ |
| 142 | | :const:`EPOLLMSG` | ??? | |
| 143 | +-----------------------+-----------------------------------------------+ |
| 144 | |
| 145 | |
| 146 | .. method:: epoll.close() |
| 147 | |
| 148 | Close the control file descriptor of the epoll object. |
| 149 | |
| 150 | |
| 151 | .. method:: epoll.fileno() |
| 152 | |
| 153 | Return the file descriptor number of the control fd. |
| 154 | |
| 155 | |
| 156 | .. method:: epoll.fromfd(fd) |
| 157 | |
| 158 | Create an epoll object from a given file descriptor. |
| 159 | |
| 160 | |
| 161 | .. method:: epoll.register(fd[, eventmask]) |
| 162 | |
| 163 | Register a fd descriptor with the epoll object. |
| 164 | |
R. David Murray | 1855c21 | 2009-05-31 19:44:27 +0000 | [diff] [blame] | 165 | .. note:: |
| 166 | |
| 167 | Registering a file descriptor that's already registered raises an |
| 168 | IOError -- contrary to :ref:`poll-objects`'s register. |
| 169 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 170 | |
| 171 | .. method:: epoll.modify(fd, eventmask) |
| 172 | |
| 173 | Modify a register file descriptor. |
| 174 | |
| 175 | |
| 176 | .. method:: epoll.unregister(fd) |
| 177 | |
| 178 | Remove a registered file descriptor from the epoll object. |
| 179 | |
| 180 | |
| 181 | .. method:: epoll.poll([timeout=-1[, maxevents=-1]]) |
| 182 | |
| 183 | Wait for events. timeout in seconds (float) |
| 184 | |
| 185 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 186 | .. _poll-objects: |
| 187 | |
| 188 | Polling Objects |
| 189 | --------------- |
| 190 | |
| 191 | The :cfunc:`poll` system call, supported on most Unix systems, provides better |
| 192 | scalability for network servers that service many, many clients at the same |
| 193 | time. :cfunc:`poll` scales better because the system call only requires listing |
| 194 | the file descriptors of interest, while :cfunc:`select` builds a bitmap, turns |
| 195 | on bits for the fds of interest, and then afterward the whole bitmap has to be |
| 196 | linearly scanned again. :cfunc:`select` is O(highest file descriptor), while |
| 197 | :cfunc:`poll` is O(number of file descriptors). |
| 198 | |
| 199 | |
| 200 | .. method:: poll.register(fd[, eventmask]) |
| 201 | |
| 202 | Register a file descriptor with the polling object. Future calls to the |
| 203 | :meth:`poll` method will then check whether the file descriptor has any pending |
| 204 | I/O events. *fd* can be either an integer, or an object with a :meth:`fileno` |
| 205 | method that returns an integer. File objects implement :meth:`fileno`, so they |
| 206 | can also be used as the argument. |
| 207 | |
| 208 | *eventmask* is an optional bitmask describing the type of events you want to |
| 209 | check for, and can be a combination of the constants :const:`POLLIN`, |
| 210 | :const:`POLLPRI`, and :const:`POLLOUT`, described in the table below. If not |
| 211 | specified, the default value used will check for all 3 types of events. |
| 212 | |
| 213 | +-------------------+------------------------------------------+ |
| 214 | | Constant | Meaning | |
| 215 | +===================+==========================================+ |
| 216 | | :const:`POLLIN` | There is data to read | |
| 217 | +-------------------+------------------------------------------+ |
| 218 | | :const:`POLLPRI` | There is urgent data to read | |
| 219 | +-------------------+------------------------------------------+ |
| 220 | | :const:`POLLOUT` | Ready for output: writing will not block | |
| 221 | +-------------------+------------------------------------------+ |
| 222 | | :const:`POLLERR` | Error condition of some sort | |
| 223 | +-------------------+------------------------------------------+ |
| 224 | | :const:`POLLHUP` | Hung up | |
| 225 | +-------------------+------------------------------------------+ |
| 226 | | :const:`POLLNVAL` | Invalid request: descriptor not open | |
| 227 | +-------------------+------------------------------------------+ |
| 228 | |
| 229 | Registering a file descriptor that's already registered is not an error, and has |
| 230 | the same effect as registering the descriptor exactly once. |
| 231 | |
| 232 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 233 | .. method:: poll.modify(fd, eventmask) |
| 234 | |
| 235 | Modifies an already registered fd. This has the same effect as |
| 236 | :meth:`register(fd, eventmask)`. Attempting to modify a file descriptor |
| 237 | that was never registered causes an :exc:`IOError` exception with errno |
| 238 | :const:`ENOENT` to be raised. |
| 239 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 240 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 241 | .. method:: poll.unregister(fd) |
| 242 | |
| 243 | Remove a file descriptor being tracked by a polling object. Just like the |
| 244 | :meth:`register` method, *fd* can be an integer or an object with a |
| 245 | :meth:`fileno` method that returns an integer. |
| 246 | |
| 247 | Attempting to remove a file descriptor that was never registered causes a |
| 248 | :exc:`KeyError` exception to be raised. |
| 249 | |
| 250 | |
| 251 | .. method:: poll.poll([timeout]) |
| 252 | |
| 253 | Polls the set of registered file descriptors, and returns a possibly-empty list |
| 254 | containing ``(fd, event)`` 2-tuples for the descriptors that have events or |
| 255 | errors to report. *fd* is the file descriptor, and *event* is a bitmask with |
| 256 | bits set for the reported events for that descriptor --- :const:`POLLIN` for |
| 257 | waiting input, :const:`POLLOUT` to indicate that the descriptor can be written |
| 258 | to, and so forth. An empty list indicates that the call timed out and no file |
| 259 | descriptors had any events to report. If *timeout* is given, it specifies the |
| 260 | length of time in milliseconds which the system will wait for events before |
| 261 | returning. If *timeout* is omitted, negative, or :const:`None`, the call will |
| 262 | block until there is an event for this poll object. |
| 263 | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 264 | |
| 265 | .. _kqueue-objects: |
| 266 | |
| 267 | Kqueue Objects |
| 268 | -------------- |
| 269 | |
| 270 | .. method:: kqueue.close() |
| 271 | |
| 272 | Close the control file descriptor of the kqueue object. |
| 273 | |
| 274 | |
| 275 | .. method:: kqueue.fileno() |
| 276 | |
| 277 | Return the file descriptor number of the control fd. |
| 278 | |
| 279 | |
Benjamin Peterson | 9bc9351 | 2008-09-22 22:10:59 +0000 | [diff] [blame] | 280 | .. method:: kqueue.fromfd(fd) |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 281 | |
| 282 | Create a kqueue object from a given file descriptor. |
| 283 | |
| 284 | |
Benjamin Peterson | 9bc9351 | 2008-09-22 22:10:59 +0000 | [diff] [blame] | 285 | .. method:: kqueue.control(changelist, max_events[, timeout=None]) -> eventlist |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 286 | |
| 287 | Low level interface to kevent |
| 288 | |
| 289 | - changelist must be an iterable of kevent object or None |
| 290 | - max_events must be 0 or a positive integer |
| 291 | - timeout in seconds (floats possible) |
| 292 | |
| 293 | |
| 294 | .. _kevent-objects: |
| 295 | |
| 296 | Kevent Objects |
| 297 | -------------- |
| 298 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 299 | http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 300 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 301 | .. attribute:: kevent.ident |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 302 | |
| 303 | Value used to identify the event. The interpretation depends on the filter |
| 304 | but it's usually the file descriptor. In the constructor ident can either |
| 305 | be an int or an object with a fileno() function. kevent stores the integer |
| 306 | internally. |
| 307 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 308 | .. attribute:: kevent.filter |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 309 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 310 | Name of the kernel filter. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 311 | |
| 312 | +---------------------------+---------------------------------------------+ |
| 313 | | Constant | Meaning | |
| 314 | +===========================+=============================================+ |
| 315 | | :const:`KQ_FILTER_READ` | Takes a descriptor and returns whenever | |
| 316 | | | there is data available to read | |
| 317 | +---------------------------+---------------------------------------------+ |
| 318 | | :const:`KQ_FILTER_WRITE` | Takes a descriptor and returns whenever | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 319 | | | there is data available to write | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 320 | +---------------------------+---------------------------------------------+ |
| 321 | | :const:`KQ_FILTER_AIO` | AIO requests | |
| 322 | +---------------------------+---------------------------------------------+ |
| 323 | | :const:`KQ_FILTER_VNODE` | Returns when one or more of the requested | |
| 324 | | | events watched in *fflag* occurs | |
| 325 | +---------------------------+---------------------------------------------+ |
| 326 | | :const:`KQ_FILTER_PROC` | Watch for events on a process id | |
| 327 | +---------------------------+---------------------------------------------+ |
| 328 | | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device | |
| 329 | | | [not available on Mac OS X] | |
| 330 | +---------------------------+---------------------------------------------+ |
| 331 | | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is | |
| 332 | | | delivered to the process | |
| 333 | +---------------------------+---------------------------------------------+ |
| 334 | | :const:`KQ_FILTER_TIMER` | Establishes an arbitrary timer | |
| 335 | +---------------------------+---------------------------------------------+ |
| 336 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 337 | .. attribute:: kevent.flags |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 338 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 339 | Filter action. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 340 | |
| 341 | +---------------------------+---------------------------------------------+ |
| 342 | | Constant | Meaning | |
| 343 | +===========================+=============================================+ |
| 344 | | :const:`KQ_EV_ADD` | Adds or modifies an event | |
| 345 | +---------------------------+---------------------------------------------+ |
| 346 | | :const:`KQ_EV_DELETE` | Removes an event from the queue | |
| 347 | +---------------------------+---------------------------------------------+ |
| 348 | | :const:`KQ_EV_ENABLE` | Permitscontrol() to returns the event | |
| 349 | +---------------------------+---------------------------------------------+ |
| 350 | | :const:`KQ_EV_DISABLE` | Disablesevent | |
| 351 | +---------------------------+---------------------------------------------+ |
Georg Brandl | 2ee470f | 2008-07-16 12:55:28 +0000 | [diff] [blame] | 352 | | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 353 | +---------------------------+---------------------------------------------+ |
| 354 | | :const:`KQ_EV_CLEAR` | Reset the state after an event is retrieved | |
| 355 | +---------------------------+---------------------------------------------+ |
| 356 | | :const:`KQ_EV_SYSFLAGS` | internal event | |
| 357 | +---------------------------+---------------------------------------------+ |
| 358 | | :const:`KQ_EV_FLAG1` | internal event | |
| 359 | +---------------------------+---------------------------------------------+ |
| 360 | | :const:`KQ_EV_EOF` | Filter specific EOF condition | |
| 361 | +---------------------------+---------------------------------------------+ |
| 362 | | :const:`KQ_EV_ERROR` | See return values | |
| 363 | +---------------------------+---------------------------------------------+ |
| 364 | |
| 365 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 366 | .. attribute:: kevent.fflags |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 367 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 368 | Filter specific flags. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 369 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 370 | :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags: |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 371 | |
| 372 | +----------------------------+--------------------------------------------+ |
| 373 | | Constant | Meaning | |
| 374 | +============================+============================================+ |
| 375 | | :const:`KQ_NOTE_LOWAT` | low water mark of a socket buffer | |
| 376 | +----------------------------+--------------------------------------------+ |
| 377 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 378 | :const:`KQ_FILTER_VNODE` filter flags: |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 379 | |
| 380 | +----------------------------+--------------------------------------------+ |
| 381 | | Constant | Meaning | |
| 382 | +============================+============================================+ |
| 383 | | :const:`KQ_NOTE_DELETE` | *unlink()* was called | |
| 384 | +----------------------------+--------------------------------------------+ |
Georg Brandl | 2ee470f | 2008-07-16 12:55:28 +0000 | [diff] [blame] | 385 | | :const:`KQ_NOTE_WRITE` | a write occurred | |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 386 | +----------------------------+--------------------------------------------+ |
| 387 | | :const:`KQ_NOTE_EXTEND` | the file was extended | |
| 388 | +----------------------------+--------------------------------------------+ |
| 389 | | :const:`KQ_NOTE_ATTRIB` | an attribute was changed | |
| 390 | +----------------------------+--------------------------------------------+ |
| 391 | | :const:`KQ_NOTE_LINK` | the link count has changed | |
| 392 | +----------------------------+--------------------------------------------+ |
| 393 | | :const:`KQ_NOTE_RENAME` | the file was renamed | |
| 394 | +----------------------------+--------------------------------------------+ |
| 395 | | :const:`KQ_NOTE_REVOKE` | access to the file was revoked | |
| 396 | +----------------------------+--------------------------------------------+ |
| 397 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 398 | :const:`KQ_FILTER_PROC` filter flags: |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 399 | |
| 400 | +----------------------------+--------------------------------------------+ |
| 401 | | Constant | Meaning | |
| 402 | +============================+============================================+ |
| 403 | | :const:`KQ_NOTE_EXIT` | the process has exited | |
| 404 | +----------------------------+--------------------------------------------+ |
| 405 | | :const:`KQ_NOTE_FORK` | the process has called *fork()* | |
| 406 | +----------------------------+--------------------------------------------+ |
| 407 | | :const:`KQ_NOTE_EXEC` | the process has executed a new process | |
| 408 | +----------------------------+--------------------------------------------+ |
| 409 | | :const:`KQ_NOTE_PCTRLMASK` | internal filter flag | |
| 410 | +----------------------------+--------------------------------------------+ |
| 411 | | :const:`KQ_NOTE_PDATAMASK` | internal filter flag | |
| 412 | +----------------------------+--------------------------------------------+ |
| 413 | | :const:`KQ_NOTE_TRACK` | follow a process across *fork()* | |
| 414 | +----------------------------+--------------------------------------------+ |
| 415 | | :const:`KQ_NOTE_CHILD` | returned on the child process for | |
| 416 | | | *NOTE_TRACK* | |
| 417 | +----------------------------+--------------------------------------------+ |
| 418 | | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child | |
| 419 | +----------------------------+--------------------------------------------+ |
| 420 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 421 | :const:`KQ_FILTER_NETDEV` filter flags (not available on Mac OS X): |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 422 | |
| 423 | +----------------------------+--------------------------------------------+ |
| 424 | | Constant | Meaning | |
| 425 | +============================+============================================+ |
| 426 | | :const:`KQ_NOTE_LINKUP` | link is up | |
| 427 | +----------------------------+--------------------------------------------+ |
| 428 | | :const:`KQ_NOTE_LINKDOWN` | link is down | |
| 429 | +----------------------------+--------------------------------------------+ |
| 430 | | :const:`KQ_NOTE_LINKINV` | link state is invalid | |
| 431 | +----------------------------+--------------------------------------------+ |
| 432 | |
| 433 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 434 | .. attribute:: kevent.data |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 435 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 436 | Filter specific data. |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 437 | |
| 438 | |
Christian Heimes | fe337bf | 2008-03-23 21:54:12 +0000 | [diff] [blame] | 439 | .. attribute:: kevent.udata |
Christian Heimes | 4fbc72b | 2008-03-22 00:47:35 +0000 | [diff] [blame] | 440 | |
Georg Brandl | 1b5ab45 | 2009-08-13 07:56:35 +0000 | [diff] [blame] | 441 | User defined value. |