1.\" Copyright (c) 2000 Jonathan Lemon 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd October 6, 2021 28.Dt KQUEUE 2 29.Os 30.Sh NAME 31.Nm kqueue , 32.Nm kevent 33.Nd kernel event notification mechanism 34.Sh LIBRARY 35.Lb libc 36.Sh SYNOPSIS 37.In sys/event.h 38.Ft int 39.Fn kqueue "void" 40.Ft int 41.Fo kevent 42.Fa "int kq" 43.Fa "const struct kevent *changelist" 44.Fa "int nchanges" 45.Fa "struct kevent *eventlist" 46.Fa "int nevents" 47.Fa "const struct timespec *timeout" 48.Fc 49.Fn EV_SET "kev" ident filter flags fflags data udata 50.Sh DESCRIPTION 51The 52.Fn kqueue 53system call 54provides a generic method of notifying the user when an event 55happens or a condition holds, based on the results of small 56pieces of kernel code termed filters. 57A kevent is identified by the (ident, filter) pair; there may only 58be one unique kevent per kqueue. 59.Pp 60The filter is executed upon the initial registration of a kevent 61in order to detect whether a preexisting condition is present, and is also 62executed whenever an event is passed to the filter for evaluation. 63If the filter determines that the condition should be reported, 64then the kevent is placed on the kqueue for the user to retrieve. 65.Pp 66The filter is also run when the user attempts to retrieve the kevent 67from the kqueue. 68If the filter indicates that the condition that triggered 69the event no longer holds, the kevent is removed from the kqueue and 70is not returned. 71.Pp 72Multiple events which trigger the filter do not result in multiple 73kevents being placed on the kqueue; instead, the filter will aggregate 74the events into a single struct kevent. 75Calling 76.Fn close 77on a file descriptor will remove any kevents that reference the descriptor. 78.Pp 79The 80.Fn kqueue 81system call 82creates a new kernel event queue and returns a descriptor. 83The queue is not inherited by a child created with 84.Xr fork 2 . 85However, if 86.Xr rfork 2 87is called without the 88.Dv RFFDG 89flag, then the descriptor table is shared, 90which will allow sharing of the kqueue between two processes. 91.Pp 92The 93.Fn kevent 94system call 95is used to register events with the queue, and return any pending 96events to the user. 97The 98.Fa changelist 99argument 100is a pointer to an array of 101.Va kevent 102structures, as defined in 103.In sys/event.h . 104All changes contained in the 105.Fa changelist 106are applied before any pending events are read from the queue. 107The 108.Fa nchanges 109argument 110gives the size of 111.Fa changelist . 112The 113.Fa eventlist 114argument 115is a pointer to an array of kevent structures. 116The 117.Fa nevents 118argument 119determines the size of 120.Fa eventlist . 121When 122.Fa nevents 123is zero, 124.Fn kevent 125will return immediately even if there is a 126.Fa timeout 127specified unlike 128.Xr select 2 . 129If 130.Fa timeout 131is a non-NULL pointer, it specifies a maximum interval to wait 132for an event, which will be interpreted as a struct timespec. 133If 134.Fa timeout 135is a NULL pointer, 136.Fn kevent 137waits indefinitely. 138To effect a poll, the 139.Fa timeout 140argument should be non-NULL, pointing to a zero-valued 141.Va timespec 142structure. 143The same array may be used for the 144.Fa changelist 145and 146.Fa eventlist . 147.Pp 148The 149.Fn EV_SET 150macro is provided for ease of initializing a 151kevent structure. 152.Pp 153The 154.Va kevent 155structure is defined as: 156.Bd -literal 157struct kevent { 158 uintptr_t ident; /* identifier for this event */ 159 short filter; /* filter for event */ 160 u_short flags; /* action flags for kqueue */ 161 u_int fflags; /* filter flag value */ 162 int64_t data; /* filter data value */ 163 void *udata; /* opaque user data identifier */ 164 uint64_t ext[4]; /* extensions */ 165}; 166.Ed 167.Pp 168The fields of 169.Fa struct kevent 170are: 171.Bl -tag -width "Fa filter" 172.It Fa ident 173Value used to identify this event. 174The exact interpretation is determined by the attached filter, 175but often is a file descriptor. 176.It Fa filter 177Identifies the kernel filter used to process this event. 178The pre-defined 179system filters are described below. 180.It Fa flags 181Actions to perform on the event. 182.It Fa fflags 183Filter-specific flags. 184.It Fa data 185Filter-specific data value. 186.It Fa udata 187Opaque user-defined value passed through the kernel unchanged. 188.It Fa ext 189Extended data passed to and from kernel. 190The 191.Fa ext[0] 192and 193.Fa ext[1] 194members use is defined by the filter. 195If the filter does not use them, the members are copied unchanged. 196The 197.Fa ext[2] 198and 199.Fa ext[3] 200members are always passed through the kernel as-is, 201making additional context available to application. 202.El 203.Pp 204The 205.Va flags 206field can contain the following values: 207.Bl -tag -width EV_DISPATCH 208.It Dv EV_ADD 209Adds the event to the kqueue. 210Re-adding an existing event 211will modify the parameters of the original event, and not result 212in a duplicate entry. 213Adding an event automatically enables it, 214unless overridden by the EV_DISABLE flag. 215.It Dv EV_ENABLE 216Permit 217.Fn kevent 218to return the event if it is triggered. 219.It Dv EV_DISABLE 220Disable the event so 221.Fn kevent 222will not return it. 223The filter itself is not disabled. 224.It Dv EV_DISPATCH 225Disable the event source immediately after delivery of an event. 226See 227.Dv EV_DISABLE 228above. 229.It Dv EV_DELETE 230Removes the event from the kqueue. 231Events which are attached to 232file descriptors are automatically deleted on the last close of 233the descriptor. 234.It Dv EV_RECEIPT 235This flag is useful for making bulk changes to a kqueue without draining 236any pending events. 237When passed as input, it forces 238.Dv EV_ERROR 239to always be returned. 240When a filter is successfully added the 241.Va data 242field will be zero. 243Note that if this flag is encountered and there is no remaining space in 244.Fa eventlist 245to hold the 246.Dv EV_ERROR 247event, then subsequent changes will not get processed. 248.It Dv EV_ONESHOT 249Causes the event to return only the first occurrence of the filter 250being triggered. 251After the user retrieves the event from the kqueue, 252it is deleted. 253.It Dv EV_CLEAR 254After the event is retrieved by the user, its state is reset. 255This is useful for filters which report state transitions 256instead of the current state. 257Note that some filters may automatically 258set this flag internally. 259.It Dv EV_EOF 260Filters may set this flag to indicate filter-specific EOF condition. 261.It Dv EV_ERROR 262See 263.Sx RETURN VALUES 264below. 265.El 266.Pp 267The predefined system filters are listed below. 268Arguments may be passed to and from the filter via the 269.Va fflags 270and 271.Va data 272fields in the kevent structure. 273.Bl -tag -width "Dv EVFILT_PROCDESC" 274.It Dv EVFILT_READ 275Takes a descriptor as the identifier, and returns whenever 276there is data available to read. 277The behavior of the filter is slightly different depending 278on the descriptor type. 279.Bl -tag -width 2n 280.It Sockets 281Sockets which have previously been passed to 282.Fn listen 283return when there is an incoming connection pending. 284.Va data 285contains the size of the listen backlog. 286.Pp 287Other socket descriptors return when there is data to be read, 288subject to the 289.Dv SO_RCVLOWAT 290value of the socket buffer. 291This may be overridden with a per-filter low water mark at the 292time the filter is added by setting the 293.Dv NOTE_LOWAT 294flag in 295.Va fflags , 296and specifying the new low water mark in 297.Va data . 298On return, 299.Va data 300contains the number of bytes of protocol data available to read. 301.Pp 302If the read direction of the socket has shutdown, then the filter 303also sets 304.Dv EV_EOF 305in 306.Va flags , 307and returns the socket error (if any) in 308.Va fflags . 309It is possible for EOF to be returned (indicating the connection is gone) 310while there is still data pending in the socket buffer. 311.It Vnodes 312Returns when the file pointer is not at the end of file. 313.Va data 314contains the offset from current position to end of file, 315and may be negative. 316.Pp 317This behavior is different from 318.Xr poll 2 , 319where read events are triggered for regular files unconditionally. 320This event can be triggered unconditionally by setting the 321.Dv NOTE_FILE_POLL 322flag in 323.Va fflags . 324.It "Fifos, Pipes" 325Returns when the there is data to read; 326.Va data 327contains the number of bytes available. 328.Pp 329When the last writer disconnects, the filter will set 330.Dv EV_EOF 331in 332.Va flags . 333This will be cleared by the filter when a new writer connects, 334at which point the 335filter will resume waiting for data to become available before 336returning. 337.It "BPF devices" 338Returns when the BPF buffer is full, the BPF timeout has expired, or 339when the BPF has 340.Dq immediate mode 341enabled and there is any data to read; 342.Va data 343contains the number of bytes available. 344.It Eventfds 345Returns when the counter is greater than 0; 346.Va data 347contains the counter value, which must be cast to 348.Vt uint64_t . 349.It Kqueues 350Returns when pending events are present on the queue; 351.Va data 352contains the number of events available. 353.El 354.It Dv EVFILT_WRITE 355Takes a descriptor as the identifier, and returns whenever 356it is possible to write to the descriptor. 357For sockets, pipes 358and fifos, 359.Va data 360will contain the amount of space remaining in the write buffer. 361The filter will set 362.Dv EV_EOF 363when the reader disconnects, and for the fifo case, this will be cleared 364when a new reader connects. 365Note that this filter is not supported for vnodes or BPF devices. 366.Pp 367For sockets, the low water mark and socket error handling is 368identical to the 369.Dv EVFILT_READ 370case. 371.Pp 372For eventfds, 373.Va data 374will contain the maximum value that can be added to the counter 375without blocking. 376.It Dv EVFILT_EMPTY 377Takes a descriptor as the identifier, and returns whenever 378there is no remaining data in the write buffer. 379.It Dv EVFILT_AIO 380Events for this filter are not registered with 381.Fn kevent 382directly but are registered via the 383.Va aio_sigevent 384member of an asynchronous I/O request when it is scheduled via an 385asynchronous I/O system call such as 386.Fn aio_read . 387The filter returns under the same conditions as 388.Fn aio_error . 389For more details on this filter see 390.Xr sigevent 3 and 391.Xr aio 4 . 392.It Dv EVFILT_VNODE 393Takes a file descriptor as the identifier and the events to watch for in 394.Va fflags , 395and returns when one or more of the requested events occurs on the descriptor. 396The events to monitor are: 397.Bl -tag -width "Dv NOTE_CLOSE_WRITE" 398.It Dv NOTE_ATTRIB 399The file referenced by the descriptor had its attributes changed. 400.It Dv NOTE_CLOSE 401A file descriptor referencing the monitored file, was closed. 402The closed file descriptor did not have write access. 403.It Dv NOTE_CLOSE_WRITE 404A file descriptor referencing the monitored file, was closed. 405The closed file descriptor had write access. 406.Pp 407This note, as well as 408.Dv NOTE_CLOSE , 409are not activated when files are closed forcibly by 410.Xr unmount 2 or 411.Xr revoke 2 . 412Instead, 413.Dv NOTE_REVOKE 414is sent for such events. 415.It Dv NOTE_DELETE 416The 417.Fn unlink 418system call was called on the file referenced by the descriptor. 419.It Dv NOTE_EXTEND 420For regular file, the file referenced by the descriptor was extended. 421.Pp 422For directory, reports that a directory entry was added or removed, 423as the result of rename operation. 424The 425.Dv NOTE_EXTEND 426event is not reported when a name is changed inside the directory. 427.It Dv NOTE_LINK 428The link count on the file changed. 429In particular, the 430.Dv NOTE_LINK 431event is reported if a subdirectory was created or deleted inside 432the directory referenced by the descriptor. 433.It Dv NOTE_OPEN 434The file referenced by the descriptor was opened. 435.It Dv NOTE_READ 436A read occurred on the file referenced by the descriptor. 437.It Dv NOTE_RENAME 438The file referenced by the descriptor was renamed. 439.It Dv NOTE_REVOKE 440Access to the file was revoked via 441.Xr revoke 2 442or the underlying file system was unmounted. 443.It Dv NOTE_WRITE 444A write occurred on the file referenced by the descriptor. 445.El 446.Pp 447On return, 448.Va fflags 449contains the events which triggered the filter. 450.It Dv EVFILT_PROC 451Takes the process ID to monitor as the identifier and the events to watch for 452in 453.Va fflags , 454and returns when the process performs one or more of the requested events. 455If a process can normally see another process, it can attach an event to it. 456The events to monitor are: 457.Bl -tag -width "Dv NOTE_TRACKERR" 458.It Dv NOTE_EXIT 459The process has exited. 460The exit status will be stored in 461.Va data . 462.It Dv NOTE_FORK 463The process has called 464.Fn fork . 465.It Dv NOTE_EXEC 466The process has executed a new process via 467.Xr execve 2 468or a similar call. 469.It Dv NOTE_TRACK 470Follow a process across 471.Fn fork 472calls. 473The parent process registers a new kevent to monitor the child process 474using the same 475.Va fflags 476as the original event. 477The child process will signal an event with 478.Dv NOTE_CHILD 479set in 480.Va fflags 481and the parent PID in 482.Va data . 483.Pp 484If the parent process fails to register a new kevent 485.Pq usually due to resource limitations , 486it will signal an event with 487.Dv NOTE_TRACKERR 488set in 489.Va fflags , 490and the child process will not signal a 491.Dv NOTE_CHILD 492event. 493.El 494.Pp 495On return, 496.Va fflags 497contains the events which triggered the filter. 498.It Dv EVFILT_PROCDESC 499Takes the process descriptor created by 500.Xr pdfork 2 501to monitor as the identifier and the events to watch for in 502.Va fflags , 503and returns when the associated process performs one or more of the 504requested events. 505The events to monitor are: 506.Bl -tag -width "Dv NOTE_EXIT" 507.It Dv NOTE_EXIT 508The process has exited. 509The exit status will be stored in 510.Va data . 511.El 512.Pp 513On return, 514.Va fflags 515contains the events which triggered the filter. 516.It Dv EVFILT_SIGNAL 517Takes the signal number to monitor as the identifier and returns 518when the given signal is delivered to the process. 519This coexists with the 520.Fn signal 521and 522.Fn sigaction 523facilities, and has a lower precedence. 524The filter will record 525all attempts to deliver a signal to a process, even if the signal has 526been marked as 527.Dv SIG_IGN , 528except for the 529.Dv SIGCHLD 530signal, which, if ignored, will not be recorded by the filter. 531Event notification happens after normal 532signal delivery processing. 533.Va data 534returns the number of times the signal has occurred since the last call to 535.Fn kevent . 536This filter automatically sets the 537.Dv EV_CLEAR 538flag internally. 539.It Dv EVFILT_TIMER 540Establishes an arbitrary timer identified by 541.Va ident . 542When adding a timer, 543.Va data 544specifies the moment to fire the timer (for 545.Dv NOTE_ABSTIME ) 546or the timeout period. 547The timer will be periodic unless 548.Dv EV_ONESHOT 549or 550.Dv NOTE_ABSTIME 551is specified. 552On return, 553.Va data 554contains the number of times the timeout has expired since the last call to 555.Fn kevent . 556For non-monotonic timers, this filter automatically sets the 557.Dv EV_CLEAR 558flag internally. 559.Pp 560The filter accepts the following flags in the 561.Va fflags 562argument: 563.Bl -tag -width "Dv NOTE_MSECONDS" 564.It Dv NOTE_SECONDS 565.Va data 566is in seconds. 567.It Dv NOTE_MSECONDS 568.Va data 569is in milliseconds. 570.It Dv NOTE_USECONDS 571.Va data 572is in microseconds. 573.It Dv NOTE_NSECONDS 574.Va data 575is in nanoseconds. 576.It Dv NOTE_ABSTIME 577The specified expiration time is absolute. 578.El 579.Pp 580If 581.Va fflags 582is not set, the default is milliseconds. 583On return, 584.Va fflags 585contains the events which triggered the filter. 586.Pp 587Periodic timers with a specified timeout of 0 will be silently adjusted to 588timeout after 1 of the time units specified by the requested precision in 589.Va fflags . 590If an absolute time is specified that has already passed, then it is treated as 591if the current time were specified and the event will fire as soon as possible. 592.Pp 593If an existing timer is re-added, the existing timer will be 594effectively canceled (throwing away any undelivered record of previous 595timer expiration) and re-started using the new parameters contained in 596.Va data 597and 598.Va fflags . 599.Pp 600There is a system wide limit on the number of timers 601which is controlled by the 602.Va kern.kq_calloutmax 603sysctl. 604.It Dv EVFILT_USER 605Establishes a user event identified by 606.Va ident 607which is not associated with any kernel mechanism but is triggered by 608user level code. 609The lower 24 bits of the 610.Va fflags 611may be used for user defined flags and manipulated using the following: 612.Bl -tag -width "Dv NOTE_FFLAGSMASK" 613.It Dv NOTE_FFNOP 614Ignore the input 615.Va fflags . 616.It Dv NOTE_FFAND 617Bitwise AND 618.Va fflags . 619.It Dv NOTE_FFOR 620Bitwise OR 621.Va fflags . 622.It Dv NOTE_FFCOPY 623Copy 624.Va fflags . 625.It Dv NOTE_FFCTRLMASK 626Control mask for 627.Va fflags . 628.It Dv NOTE_FFLAGSMASK 629User defined flag mask for 630.Va fflags . 631.El 632.Pp 633A user event is triggered for output with the following: 634.Bl -tag -width "Dv NOTE_FFLAGSMASK" 635.It Dv NOTE_TRIGGER 636Cause the event to be triggered. 637.El 638.Pp 639On return, 640.Va fflags 641contains the users defined flags in the lower 24 bits. 642.El 643.Sh CANCELLATION BEHAVIOUR 644If 645.Fa nevents 646is non-zero, i.e., the function is potentially blocking, the call 647is a cancellation point. 648Otherwise, i.e., if 649.Fa nevents 650is zero, the call is not cancellable. 651Cancellation can only occur before any changes are made to the kqueue, 652or when the call was blocked and no changes to the queue were requested. 653.Sh RETURN VALUES 654The 655.Fn kqueue 656system call 657creates a new kernel event queue and returns a file descriptor. 658If there was an error creating the kernel event queue, a value of -1 is 659returned and errno set. 660.Pp 661The 662.Fn kevent 663system call 664returns the number of events placed in the 665.Fa eventlist , 666up to the value given by 667.Fa nevents . 668If an error occurs while processing an element of the 669.Fa changelist 670and there is enough room in the 671.Fa eventlist , 672then the event will be placed in the 673.Fa eventlist 674with 675.Dv EV_ERROR 676set in 677.Va flags 678and the system error in 679.Va data . 680Otherwise, 681.Dv -1 682will be returned, and 683.Dv errno 684will be set to indicate the error condition. 685If the time limit expires, then 686.Fn kevent 687returns 0. 688.Sh EXAMPLES 689.Bd -literal -compact 690#include <sys/event.h> 691#include <err.h> 692#include <fcntl.h> 693#include <stdio.h> 694#include <stdlib.h> 695#include <string.h> 696 697int 698main(int argc, char **argv) 699{ 700 struct kevent event; /* Event we want to monitor */ 701 struct kevent tevent; /* Event triggered */ 702 int kq, fd, ret; 703 704 if (argc != 2) 705 err(EXIT_FAILURE, "Usage: %s path\en", argv[0]); 706 fd = open(argv[1], O_RDONLY); 707 if (fd == -1) 708 err(EXIT_FAILURE, "Failed to open '%s'", argv[1]); 709 710 /* Create kqueue. */ 711 kq = kqueue(); 712 if (kq == -1) 713 err(EXIT_FAILURE, "kqueue() failed"); 714 715 /* Initialize kevent structure. */ 716 EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE, 717 0, NULL); 718 /* Attach event to the kqueue. */ 719 ret = kevent(kq, &event, 1, NULL, 0, NULL); 720 if (ret == -1) 721 err(EXIT_FAILURE, "kevent register"); 722 if (event.flags & EV_ERROR) 723 errx(EXIT_FAILURE, "Event error: %s", strerror(event.data)); 724 725 for (;;) { 726 /* Sleep until something happens. */ 727 ret = kevent(kq, NULL, 0, &tevent, 1, NULL); 728 if (ret == -1) { 729 err(EXIT_FAILURE, "kevent wait"); 730 } else if (ret > 0) { 731 printf("Something was written in '%s'\en", argv[1]); 732 } 733 } 734} 735.Ed 736.Sh ERRORS 737The 738.Fn kqueue 739system call fails if: 740.Bl -tag -width Er 741.It Bq Er ENOMEM 742The kernel failed to allocate enough memory for the kernel queue. 743.It Bq Er ENOMEM 744The 745.Dv RLIMIT_KQUEUES 746rlimit 747(see 748.Xr getrlimit 2 ) 749for the current user would be exceeded. 750.It Bq Er EMFILE 751The per-process descriptor table is full. 752.It Bq Er ENFILE 753The system file table is full. 754.El 755.Pp 756The 757.Fn kevent 758system call fails if: 759.Bl -tag -width Er 760.It Bq Er EACCES 761The process does not have permission to register a filter. 762.It Bq Er EFAULT 763There was an error reading or writing the 764.Va kevent 765structure. 766.It Bq Er EBADF 767The specified descriptor is invalid. 768.It Bq Er EINTR 769A signal was delivered before the timeout expired and before any 770events were placed on the kqueue for return. 771.It Bq Er EINTR 772A cancellation request was delivered to the thread, but not yet handled. 773.It Bq Er EINVAL 774The specified time limit or filter is invalid. 775.It Bq Er EINVAL 776The specified length of the event or change lists is negative. 777.It Bq Er ENOENT 778The event could not be found to be modified or deleted. 779.It Bq Er ENOMEM 780No memory was available to register the event 781or, in the special case of a timer, the maximum number of 782timers has been exceeded. 783This maximum is configurable via the 784.Va kern.kq_calloutmax 785sysctl. 786.It Bq Er ESRCH 787The specified process to attach to does not exist. 788.El 789.Pp 790When 791.Fn kevent 792call fails with 793.Er EINTR 794error, all changes in the 795.Fa changelist 796have been applied. 797.Sh SEE ALSO 798.Xr aio_error 2 , 799.Xr aio_read 2 , 800.Xr aio_return 2 , 801.Xr poll 2 , 802.Xr read 2 , 803.Xr select 2 , 804.Xr sigaction 2 , 805.Xr write 2 , 806.Xr pthread_setcancelstate 3 , 807.Xr signal 3 808.Rs 809.%A Jonathan Lemon 810.%T "Kqueue: A Generic and Scalable Event Notification Facility" 811.%I USENIX Association 812.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference 813.%D June 25-30, 2001 814.\".http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf 815.Re 816.Sh HISTORY 817The 818.Fn kqueue 819and 820.Fn kevent 821system calls first appeared in 822.Fx 4.1 . 823.Sh AUTHORS 824The 825.Fn kqueue 826system and this manual page were written by 827.An Jonathan Lemon Aq Mt [email protected] . 828.Sh BUGS 829The 830.Fa timeout 831value is limited to 24 hours; longer timeouts will be silently 832reinterpreted as 24 hours. 833.Pp 834In versions older than 835.Fx 12.0 , 836.In sys/event.h 837failed to parse without including 838.In sys/types.h 839manually. 840