1*ad35a4c9SJonathan Lemon.\" Copyright (c) 2000 Jonathan Lemon 2*ad35a4c9SJonathan Lemon.\" All rights reserved. 3*ad35a4c9SJonathan Lemon.\" 4*ad35a4c9SJonathan Lemon.\" Redistribution and use in source and binary forms, with or without 5*ad35a4c9SJonathan Lemon.\" modification, are permitted provided that the following conditions 6*ad35a4c9SJonathan Lemon.\" are met: 7*ad35a4c9SJonathan Lemon.\" 1. Redistributions of source code must retain the above copyright 8*ad35a4c9SJonathan Lemon.\" notice, this list of conditions and the following disclaimer. 9*ad35a4c9SJonathan Lemon.\" 2. Redistributions in binary form must reproduce the above copyright 10*ad35a4c9SJonathan Lemon.\" notice, this list of conditions and the following disclaimer in the 11*ad35a4c9SJonathan Lemon.\" documentation and/or other materials provided with the distribution. 12*ad35a4c9SJonathan Lemon.\" 13*ad35a4c9SJonathan Lemon.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND 14*ad35a4c9SJonathan Lemon.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*ad35a4c9SJonathan Lemon.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*ad35a4c9SJonathan Lemon.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*ad35a4c9SJonathan Lemon.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*ad35a4c9SJonathan Lemon.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*ad35a4c9SJonathan Lemon.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*ad35a4c9SJonathan Lemon.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*ad35a4c9SJonathan Lemon.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*ad35a4c9SJonathan Lemon.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*ad35a4c9SJonathan Lemon.\" SUCH DAMAGE. 24*ad35a4c9SJonathan Lemon.\" 25*ad35a4c9SJonathan Lemon.\" $FreeBSD$ 26*ad35a4c9SJonathan Lemon.\" 27*ad35a4c9SJonathan Lemon.Dd April 14, 2000 28*ad35a4c9SJonathan Lemon.Dt KQUEUE 2 29*ad35a4c9SJonathan Lemon.Os 30*ad35a4c9SJonathan Lemon.Sh NAME 31*ad35a4c9SJonathan Lemon.Nm kqueue, kevent 32*ad35a4c9SJonathan Lemon.Nd kernel event notification mechanism 33*ad35a4c9SJonathan Lemon.Sh SYNOPSIS 34*ad35a4c9SJonathan Lemon.Fd #include <sys/event.h> 35*ad35a4c9SJonathan Lemon.Ft int 36*ad35a4c9SJonathan Lemon.Fn kqueue "void" 37*ad35a4c9SJonathan Lemon.Ft int 38*ad35a4c9SJonathan Lemon.Fn kevent "int kq" "int nchanges" "struct kevent **changelist" \ 39*ad35a4c9SJonathan Lemon"int nevents" "struct kevent *eventlist" "struct timespec *timeout" 40*ad35a4c9SJonathan Lemon.Sh DESCRIPTION 41*ad35a4c9SJonathan Lemon.Fn kqueue 42*ad35a4c9SJonathan Lemonprovides a generic method of notifying the user when an event 43*ad35a4c9SJonathan Lemonhappens or a condition holds, based on the results of small 44*ad35a4c9SJonathan Lemonpieces of kernel code termed filters. 45*ad35a4c9SJonathan LemonAn kevent is identified by the (ident, filter) pair; there may only 46*ad35a4c9SJonathan Lemonbe one unique kevent per kqueue. 47*ad35a4c9SJonathan Lemon 48*ad35a4c9SJonathan LemonThe filter is executed upon the initial registration of a kevent 49*ad35a4c9SJonathan Lemonin order to detect a preexisting condition is present, and is also 50*ad35a4c9SJonathan Lemonexecuted whenever an event is passed to the filter for evaluation. 51*ad35a4c9SJonathan LemonIf the filter determines that the condition should be reported, 52*ad35a4c9SJonathan Lemonthen the kevent is placed on the kqueue for the user to retrieve. 53*ad35a4c9SJonathan Lemon 54*ad35a4c9SJonathan LemonThe filter is also run when the user attempts to retrieve the kevent 55*ad35a4c9SJonathan Lemonfrom the kqueue, and if the filter indicates the condition that triggered 56*ad35a4c9SJonathan Lemonthe event no longer holds, the kevent is removed from the kqueue and 57*ad35a4c9SJonathan Lemonis not returned. 58*ad35a4c9SJonathan Lemon 59*ad35a4c9SJonathan LemonMultiple events which trigger the filter do not result in multiple 60*ad35a4c9SJonathan Lemonkevents being placed on the kqueue; instead, the filter will aggregate 61*ad35a4c9SJonathan Lemonthe events into a single struct kevent. 62*ad35a4c9SJonathan LemonCalling 63*ad35a4c9SJonathan Lemon.Fn close 64*ad35a4c9SJonathan Lemonon a file descriptor will remove any kevents that reference the descriptor. 65*ad35a4c9SJonathan Lemon.Pp 66*ad35a4c9SJonathan Lemon.Fn kqueue 67*ad35a4c9SJonathan Lemoncreates a new kernel event queue and returns a descriptor. 68*ad35a4c9SJonathan Lemon.Pp 69*ad35a4c9SJonathan Lemon.Fn kevent 70*ad35a4c9SJonathan Lemonis used to register events with the queue, and return any pending 71*ad35a4c9SJonathan Lemonevents to the user. 72*ad35a4c9SJonathan Lemon.Fa changelist 73*ad35a4c9SJonathan Lemonis a pointer to an array of pointers to 74*ad35a4c9SJonathan Lemon.Va kevent 75*ad35a4c9SJonathan Lemonstructures, as defined in 76*ad35a4c9SJonathan Lemon.Aq Pa event.h . 77*ad35a4c9SJonathan LemonAll changes contained in the 78*ad35a4c9SJonathan Lemon.Fa changelist 79*ad35a4c9SJonathan Lemonare applied before any pending events are read from the queue. 80*ad35a4c9SJonathan Lemon.Fa nchanges 81*ad35a4c9SJonathan Lemongives the size of 82*ad35a4c9SJonathan Lemon.Fa changelist . 83*ad35a4c9SJonathan Lemon.Fa eventlist 84*ad35a4c9SJonathan Lemonis a pointer to an array of kevent structures. 85*ad35a4c9SJonathan Lemon.Fa nevents 86*ad35a4c9SJonathan Lemondetermines the size of 87*ad35a4c9SJonathan Lemon.Fa eventlist . 88*ad35a4c9SJonathan LemonIf 89*ad35a4c9SJonathan Lemon.Fa timeout 90*ad35a4c9SJonathan Lemonis a non-NULL pointer, it specifies a maximum interval to wait 91*ad35a4c9SJonathan Lemonfor an event. If 92*ad35a4c9SJonathan Lemon.Fa timeout 93*ad35a4c9SJonathan Lemonis a NULL pointer, 94*ad35a4c9SJonathan Lemon.Fn kevent 95*ad35a4c9SJonathan Lemonwaits indefinitely. To effect a poll, the 96*ad35a4c9SJonathan Lemon.Fa timeout 97*ad35a4c9SJonathan Lemonargument should be non-NULL, pointing to a zero-valued 98*ad35a4c9SJonathan Lemon.Va timespec 99*ad35a4c9SJonathan Lemonstructure. 100*ad35a4c9SJonathan Lemon.Pp 101*ad35a4c9SJonathan LemonThe 102*ad35a4c9SJonathan Lemon.Va kevent 103*ad35a4c9SJonathan Lemonstructure is defined as: 104*ad35a4c9SJonathan Lemon.Bd -literal 105*ad35a4c9SJonathan Lemonstruct kevent { 106*ad35a4c9SJonathan Lemon uintptr_t ident; /* identifier for this event */ 107*ad35a4c9SJonathan Lemon short filter; /* filter for event */ 108*ad35a4c9SJonathan Lemon u_short flags; /* action flags for kqueue */ 109*ad35a4c9SJonathan Lemon u_int fflags; /* filter flag value */ 110*ad35a4c9SJonathan Lemon intptr_t data; /* filter data value */ 111*ad35a4c9SJonathan Lemon void *udata; /* opaque user data identifier */ 112*ad35a4c9SJonathan Lemon}; 113*ad35a4c9SJonathan Lemon.Ed 114*ad35a4c9SJonathan Lemon.Pp 115*ad35a4c9SJonathan LemonThe fields of 116*ad35a4c9SJonathan Lemon.Fa struct kevent 117*ad35a4c9SJonathan Lemonare: 118*ad35a4c9SJonathan Lemon.Bl -tag -width XXXfilter 119*ad35a4c9SJonathan Lemon.It ident 120*ad35a4c9SJonathan LemonValue used to identify this event. 121*ad35a4c9SJonathan LemonThe exact interpretation is determined by the attached filter, 122*ad35a4c9SJonathan Lemonbut often is a file descriptor. 123*ad35a4c9SJonathan Lemon.It filter 124*ad35a4c9SJonathan LemonIdentifies the kernel filter used to process this event. The pre-defined 125*ad35a4c9SJonathan Lemonsystem filters are described below. 126*ad35a4c9SJonathan Lemon.It flags 127*ad35a4c9SJonathan LemonActions to perform on the event. 128*ad35a4c9SJonathan Lemon.It fflags 129*ad35a4c9SJonathan LemonFilter-specific flags. 130*ad35a4c9SJonathan Lemon.It data 131*ad35a4c9SJonathan LemonFilter-specific data value. 132*ad35a4c9SJonathan Lemon.It udata 133*ad35a4c9SJonathan LemonOpaque user-defined value passed through the kernel unchanged. 134*ad35a4c9SJonathan Lemon.El 135*ad35a4c9SJonathan Lemon.Pp 136*ad35a4c9SJonathan LemonThe 137*ad35a4c9SJonathan Lemon.Va flags 138*ad35a4c9SJonathan Lemonfield can contain the following values: 139*ad35a4c9SJonathan Lemon.Bl -tag -width XXXEV_ONESHOT 140*ad35a4c9SJonathan Lemon.It EV_ADD 141*ad35a4c9SJonathan LemonAdds the event to the kqueue. Re-adding an existing event 142*ad35a4c9SJonathan Lemonwill modify the parameters of the original event, and not result 143*ad35a4c9SJonathan Lemonin a duplicate entry. Adding an event automatically enables it, 144*ad35a4c9SJonathan Lemonunless overridden by the EV_DISABLE flag. 145*ad35a4c9SJonathan Lemon.It EV_ENABLE 146*ad35a4c9SJonathan LemonPermit 147*ad35a4c9SJonathan Lemon.Fn kevent 148*ad35a4c9SJonathan Lemonto return the event if it is triggered. 149*ad35a4c9SJonathan Lemon.It EV_DISABLE 150*ad35a4c9SJonathan LemonDisable the event so 151*ad35a4c9SJonathan Lemon.Fn kevent 152*ad35a4c9SJonathan Lemonwill not return it. The filter itself is not disabled. 153*ad35a4c9SJonathan Lemon.It EV_DELETE 154*ad35a4c9SJonathan LemonRemoves the event from the kqueue. Events which are attached to 155*ad35a4c9SJonathan Lemonfile descriptors are automatically deleted on the last close of 156*ad35a4c9SJonathan Lemonthe descriptor. 157*ad35a4c9SJonathan Lemon.It EV_ONESHOT 158*ad35a4c9SJonathan LemonCauses the event to return only the first occurrence of the filter 159*ad35a4c9SJonathan Lemonbeing triggered. After the user retrieves the event from the kqueue, 160*ad35a4c9SJonathan Lemonit is deleted. 161*ad35a4c9SJonathan Lemon.It EV_CLEAR 162*ad35a4c9SJonathan LemonAfter the event is retrieved by the user, its state is reset. 163*ad35a4c9SJonathan LemonThis is useful for filters which report state transitions 164*ad35a4c9SJonathan Lemoninstead of the current state. Note that some filters may automatically 165*ad35a4c9SJonathan Lemonset this flag internally. 166*ad35a4c9SJonathan Lemon.It EV_EOF 167*ad35a4c9SJonathan LemonFilters may set this flag to indicate filter-specific EOF condition. 168*ad35a4c9SJonathan Lemon.It EV_ERROR 169*ad35a4c9SJonathan LemonSee 170*ad35a4c9SJonathan Lemon.Sx RETURN VALUES 171*ad35a4c9SJonathan Lemonbelow. 172*ad35a4c9SJonathan Lemon.El 173*ad35a4c9SJonathan Lemon.Pp 174*ad35a4c9SJonathan LemonThe predefined system filters are listed below. 175*ad35a4c9SJonathan LemonArguments may be passed to and from the filter via the 176*ad35a4c9SJonathan Lemon.Va fflags 177*ad35a4c9SJonathan Lemonand 178*ad35a4c9SJonathan Lemon.Va data 179*ad35a4c9SJonathan Lemonfields in the kevent structure. 180*ad35a4c9SJonathan Lemon.Bl -tag 181*ad35a4c9SJonathan Lemon.It EVFILT_READ 182*ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever 183*ad35a4c9SJonathan Lemonthere is data available to read. 184*ad35a4c9SJonathan LemonThe behavior of the filter is slightly different depending 185*ad35a4c9SJonathan Lemonon the descriptor type. 186*ad35a4c9SJonathan Lemon.Bl -tag 187*ad35a4c9SJonathan Lemon.It Sockets 188*ad35a4c9SJonathan LemonSockets which have previously been passed to 189*ad35a4c9SJonathan Lemon.Fn listen 190*ad35a4c9SJonathan Lemonreturn when there is an incoming connection pending. 191*ad35a4c9SJonathan Lemon.Va data 192*ad35a4c9SJonathan Lemoncontains the size of the listen backlog. 193*ad35a4c9SJonathan Lemon.Pp 194*ad35a4c9SJonathan LemonOther socket descriptors return when there is data to be read, 195*ad35a4c9SJonathan Lemonsubject to the SO_RCVLOWAT value of the socket buffer. 196*ad35a4c9SJonathan Lemon.Va data 197*ad35a4c9SJonathan Lemoncontains the number of bytes in the socket buffer. 198*ad35a4c9SJonathan Lemon.Pp 199*ad35a4c9SJonathan LemonIf the read direction of the socket has shutdown, then the filter 200*ad35a4c9SJonathan Lemonalso sets EV_EOF in 201*ad35a4c9SJonathan Lemon.Va flags . 202*ad35a4c9SJonathan LemonIt is possible for EOF to be returned (indicating the connection is gone) 203*ad35a4c9SJonathan Lemonwhile there is still data pending in the socket buffer. 204*ad35a4c9SJonathan Lemon.El 205*ad35a4c9SJonathan Lemon.Bl -tag 206*ad35a4c9SJonathan Lemon.It Vnodes 207*ad35a4c9SJonathan LemonReturns when the file pointer is not at the end of file. 208*ad35a4c9SJonathan Lemon.Va data 209*ad35a4c9SJonathan Lemoncontains the offset from current position to end of file, 210*ad35a4c9SJonathan Lemonand may be negative. 211*ad35a4c9SJonathan Lemon.El 212*ad35a4c9SJonathan Lemon.Bl -tag 213*ad35a4c9SJonathan Lemon.It Fifos, Pipes 214*ad35a4c9SJonathan LemonReturns when the there is data to read; 215*ad35a4c9SJonathan Lemon.Va data 216*ad35a4c9SJonathan Lemoncontains the number of bytes available. 217*ad35a4c9SJonathan Lemon.Pp 218*ad35a4c9SJonathan LemonWhen the last writer disconnects, the filter will set EV_EOF in 219*ad35a4c9SJonathan Lemon.Va flags . 220*ad35a4c9SJonathan LemonThis may be cleared by passing in EV_CLEAR, at which point the 221*ad35a4c9SJonathan Lemonfilter will resume waiting for data to become available before 222*ad35a4c9SJonathan Lemonreturning. 223*ad35a4c9SJonathan Lemon.El 224*ad35a4c9SJonathan Lemon.El 225*ad35a4c9SJonathan Lemon.Bl -tag 226*ad35a4c9SJonathan Lemon.It EVFILT_WRITE 227*ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever 228*ad35a4c9SJonathan Lemonit is possible to write to the descriptor. For sockets, pipes 229*ad35a4c9SJonathan Lemonand fifos, 230*ad35a4c9SJonathan Lemon.Va data 231*ad35a4c9SJonathan Lemonwill contain the amount of space remaining in the write buffer. 232*ad35a4c9SJonathan LemonThe filter will set EV_EOF when the reader disconnects, and for 233*ad35a4c9SJonathan Lemonthe fifo case, this may be cleared by use of EV_CLEAR. 234*ad35a4c9SJonathan LemonNote that this filter is not supported for vnodes. 235*ad35a4c9SJonathan Lemon.El 236*ad35a4c9SJonathan Lemon.Bl -tag 237*ad35a4c9SJonathan Lemon.It EVFILT_AIO 238*ad35a4c9SJonathan LemonA kevent structure is initialized, with 239*ad35a4c9SJonathan Lemon.Va ident 240*ad35a4c9SJonathan Lemoncontaining the descriptor of the kqueue that the event should be 241*ad35a4c9SJonathan Lemonattached to. The address of the kevent structure is then placed in the 242*ad35a4c9SJonathan Lemon.Va aio_lio_opcode 243*ad35a4c9SJonathan Lemonfield of the AIO request, and the aio_* function is then called. 244*ad35a4c9SJonathan LemonThe event will be registered with the specified kqueue, and the 245*ad35a4c9SJonathan Lemon.Va ident 246*ad35a4c9SJonathan Lemonargument set to the 247*ad35a4c9SJonathan Lemon.Fa struct aiocb 248*ad35a4c9SJonathan Lemonreturned by the aio_* function. 249*ad35a4c9SJonathan LemonThe filter returns under the same conditions as aio_error. 250*ad35a4c9SJonathan Lemon.Pp 251*ad35a4c9SJonathan LemonNOTE: this interface is unstable and subject to change. 252*ad35a4c9SJonathan Lemon.El 253*ad35a4c9SJonathan Lemon.Bl -tag 254*ad35a4c9SJonathan Lemon.It EVFILT_VNODE 255*ad35a4c9SJonathan LemonTakes a file descriptor as the identifier and the events to watch for in 256*ad35a4c9SJonathan Lemon.Va fflags , 257*ad35a4c9SJonathan Lemonand returns when one or more of the requested events occurs on the descriptor. 258*ad35a4c9SJonathan LemonThe events to monitor are: 259*ad35a4c9SJonathan Lemon.Bl -tag -width XXNOTE_RENAME 260*ad35a4c9SJonathan Lemon.It NOTE_DELETE 261*ad35a4c9SJonathan Lemon.Fn unlink 262*ad35a4c9SJonathan Lemonwas called on the file referenced by the descriptor. 263*ad35a4c9SJonathan Lemon.It NOTE_WRITE 264*ad35a4c9SJonathan LemonA write occurred on the file referenced by the descriptor. 265*ad35a4c9SJonathan Lemon.It NOTE_EXTEND 266*ad35a4c9SJonathan LemonThe file referenced by the descriptor was extended. 267*ad35a4c9SJonathan Lemon.It NOTE_ATTRIB 268*ad35a4c9SJonathan LemonThe file referenced by the descriptor had its attributes changed. 269*ad35a4c9SJonathan Lemon.It NOTE_LINK 270*ad35a4c9SJonathan LemonThe link count on the file changed. 271*ad35a4c9SJonathan Lemon.It NOTE_RENAME 272*ad35a4c9SJonathan LemonThe file referenced by the descriptor was renamed. 273*ad35a4c9SJonathan Lemon.El 274*ad35a4c9SJonathan Lemon.Pp 275*ad35a4c9SJonathan LemonOn return, 276*ad35a4c9SJonathan Lemon.Va fflags 277*ad35a4c9SJonathan Lemoncontains the events which triggered the filter. 278*ad35a4c9SJonathan Lemon.El 279*ad35a4c9SJonathan Lemon.Bl -tag 280*ad35a4c9SJonathan Lemon.It EVFILT_PROC 281*ad35a4c9SJonathan LemonTakes the process ID to monitor as the identifier and the events to watch for 282*ad35a4c9SJonathan Lemonin 283*ad35a4c9SJonathan Lemon.Va fflags , 284*ad35a4c9SJonathan Lemonand returns when the process performs one or more of the requested events. 285*ad35a4c9SJonathan LemonIf a process can normally see another process, it can attach an event to it. 286*ad35a4c9SJonathan LemonThe events to monitor are: 287*ad35a4c9SJonathan Lemon.Bl -tag -width XXNOTE_TRACKERR 288*ad35a4c9SJonathan Lemon.It NOTE_EXIT 289*ad35a4c9SJonathan LemonThe process has exited. 290*ad35a4c9SJonathan Lemon.It NOTE_FORK 291*ad35a4c9SJonathan LemonThe process has called 292*ad35a4c9SJonathan Lemon.Fn fork . 293*ad35a4c9SJonathan Lemon.It NOTE_EXEC 294*ad35a4c9SJonathan LemonThe process has executed a new process via 295*ad35a4c9SJonathan Lemon.Xr execve 2 296*ad35a4c9SJonathan Lemonor similar call. 297*ad35a4c9SJonathan Lemon.It NOTE_TRACK 298*ad35a4c9SJonathan LemonFollow a process across 299*ad35a4c9SJonathan Lemon.Fn fork 300*ad35a4c9SJonathan Lemoncalls. The parent process will return with NOTE_TRACK set in the 301*ad35a4c9SJonathan Lemon.Va fflags 302*ad35a4c9SJonathan Lemonfield, while the child process will return with NOTE_CHILD set in 303*ad35a4c9SJonathan Lemon.Va fflags 304*ad35a4c9SJonathan Lemonand the parent PID in 305*ad35a4c9SJonathan Lemon.Va data . 306*ad35a4c9SJonathan Lemon.It NOTE_TRACKERR 307*ad35a4c9SJonathan LemonThis flag is returned if the system was unable to attach an event to 308*ad35a4c9SJonathan Lemonthe child process, usually due to resource limitations. 309*ad35a4c9SJonathan Lemon.El 310*ad35a4c9SJonathan Lemon.Pp 311*ad35a4c9SJonathan LemonOn return, 312*ad35a4c9SJonathan Lemon.Va fflags 313*ad35a4c9SJonathan Lemoncontains the events which triggered the filter. 314*ad35a4c9SJonathan Lemon.It EVFILT_SIGNAL 315*ad35a4c9SJonathan LemonTakes the signal number to monitor as the identifier and returns 316*ad35a4c9SJonathan Lemonwhen the given signal is delivered to the process. 317*ad35a4c9SJonathan LemonThis coexists with the 318*ad35a4c9SJonathan Lemon.Fn signal 319*ad35a4c9SJonathan Lemonand 320*ad35a4c9SJonathan Lemon.Fn sigaction 321*ad35a4c9SJonathan Lemonfacilities, and has a lower precedence. The filter will record 322*ad35a4c9SJonathan Lemonall attempts to deliver a signal to a process, even if the signal has 323*ad35a4c9SJonathan Lemonbeen marked as SIG_IGN. Event notification happens after normal 324*ad35a4c9SJonathan Lemonsignal delivery processing. 325*ad35a4c9SJonathan Lemon.Va data 326*ad35a4c9SJonathan Lemonreturns the number of times the signal has occurred since the last call to 327*ad35a4c9SJonathan Lemon.Fn kqueue . 328*ad35a4c9SJonathan LemonThis filter automatically sets the EV_CLEAR flag internally. 329*ad35a4c9SJonathan Lemon.El 330*ad35a4c9SJonathan Lemon.Sh RETURN VALUES 331*ad35a4c9SJonathan Lemon.Fn kevent 332*ad35a4c9SJonathan Lemonreturns the number of events placed in the 333*ad35a4c9SJonathan Lemon.Ar eventlist , 334*ad35a4c9SJonathan Lemonup to the value given by 335*ad35a4c9SJonathan Lemon.Ar nevents . 336*ad35a4c9SJonathan LemonIf an error occurs while processing an element of the 337*ad35a4c9SJonathan Lemon.Ar changelist 338*ad35a4c9SJonathan Lemonand there is enough room in the 339*ad35a4c9SJonathan Lemon.Ar eventlist , 340*ad35a4c9SJonathan Lemonthen the event will be placed in the 341*ad35a4c9SJonathan Lemon.Ar eventlist 342*ad35a4c9SJonathan Lemonwith 343*ad35a4c9SJonathan Lemon.Dv EV_ERROR 344*ad35a4c9SJonathan Lemonset in 345*ad35a4c9SJonathan Lemon.Va flags 346*ad35a4c9SJonathan Lemonand the system error in 347*ad35a4c9SJonathan Lemon.Va data . 348*ad35a4c9SJonathan LemonOtherwise, 349*ad35a4c9SJonathan Lemon.Dv -1 350*ad35a4c9SJonathan Lemonwill be returned, and 351*ad35a4c9SJonathan Lemon.Dv errno 352*ad35a4c9SJonathan Lemonwill be set to indicate the error condition. 353*ad35a4c9SJonathan LemonIf the time limit expires, then 354*ad35a4c9SJonathan Lemon.Fn kevent 355*ad35a4c9SJonathan Lemonreturns 0. 356*ad35a4c9SJonathan Lemon.Sh ERRORS 357*ad35a4c9SJonathan LemonThe 358*ad35a4c9SJonathan Lemon.Fn kevent 359*ad35a4c9SJonathan Lemonfunction fails if: 360*ad35a4c9SJonathan Lemon.Bl -tag -width Er 361*ad35a4c9SJonathan Lemon.It Bq Er EACCESS 362*ad35a4c9SJonathan LemonThe process does not have permission to register a filter. 363*ad35a4c9SJonathan Lemon.It Bq Er EFAULT 364*ad35a4c9SJonathan LemonThere was an error reading or writing the 365*ad35a4c9SJonathan Lemon.Va kevent 366*ad35a4c9SJonathan Lemonstructure. 367*ad35a4c9SJonathan Lemon.It Bq Er EBADF 368*ad35a4c9SJonathan LemonThe specified descriptor is invalid. 369*ad35a4c9SJonathan Lemon.It Bq Er EINTR 370*ad35a4c9SJonathan LemonA signal was delivered before the timeout expired and before any 371*ad35a4c9SJonathan Lemonevents were placed on the kqueue for return. 372*ad35a4c9SJonathan Lemon.It Bq Er EINVAL 373*ad35a4c9SJonathan LemonThe specified time limit or filter is invalid. 374*ad35a4c9SJonathan Lemon.It Bq Er ENOMEM 375*ad35a4c9SJonathan LemonNo memory was available to register the event. 376*ad35a4c9SJonathan Lemon.It Bq Er ESRCH 377*ad35a4c9SJonathan LemonThe specified process to attach to does not exist. 378*ad35a4c9SJonathan Lemon.El 379*ad35a4c9SJonathan Lemon.Sh SEE ALSO 380*ad35a4c9SJonathan Lemon.Xr aio_error 2 , 381*ad35a4c9SJonathan Lemon.Xr aio_read 2 , 382*ad35a4c9SJonathan Lemon.Xr aio_return 2 , 383*ad35a4c9SJonathan Lemon.Xr poll 2 , 384*ad35a4c9SJonathan Lemon.Xr read 2 , 385*ad35a4c9SJonathan Lemon.Xr select 2 , 386*ad35a4c9SJonathan Lemon.Xr signal 3 , 387*ad35a4c9SJonathan Lemon.Xr sigaction 2 , 388*ad35a4c9SJonathan Lemon.Xr write 2 . 389*ad35a4c9SJonathan Lemon.Sh HISTORY 390*ad35a4c9SJonathan LemonThe 391*ad35a4c9SJonathan Lemon.Fn kqueue 392*ad35a4c9SJonathan Lemonand 393*ad35a4c9SJonathan Lemon.Fn kevent 394*ad35a4c9SJonathan Lemonfunctions first appeared in 395*ad35a4c9SJonathan Lemon.Fx 5.0 . 396*ad35a4c9SJonathan Lemon.Sh AUTHOR 397*ad35a4c9SJonathan LemonThe 398*ad35a4c9SJonathan Lemon.Fn kqueue 399*ad35a4c9SJonathan Lemonsystem and this manual page were written by 400*ad35a4c9SJonathan Lemon.An Jonathan Lemon Aq [email protected] . 401