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 September 30, 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.It Dv EV_KEEPUDATA 266Causes 267.Fn kevent 268to leave unchanged any 269.Fa udata 270associated with an existing event. 271This allows other aspects of the event to be modified without requiring the 272caller to know the 273.Fa udata 274value presently associated. 275This is especially useful with 276.Dv NOTE_TRIGGER 277or flags like 278.Dv EV_ENABLE . 279This flag may not be used with 280.Dv EV_ADD . 281.El 282.Pp 283The predefined system filters are listed below. 284Arguments may be passed to and from the filter via the 285.Va fflags 286and 287.Va data 288fields in the kevent structure. 289.Bl -tag -width "Dv EVFILT_PROCDESC" 290.It Dv EVFILT_READ 291Takes a descriptor as the identifier, and returns whenever 292there is data available to read. 293The behavior of the filter is slightly different depending 294on the descriptor type. 295.Bl -tag -width 2n 296.It Sockets 297Sockets which have previously been passed to 298.Fn listen 299return when there is an incoming connection pending. 300.Va data 301contains the size of the listen backlog. 302.Pp 303Other socket descriptors return when there is data to be read, 304subject to the 305.Dv SO_RCVLOWAT 306value of the socket buffer. 307This may be overridden with a per-filter low water mark at the 308time the filter is added by setting the 309.Dv NOTE_LOWAT 310flag in 311.Va fflags , 312and specifying the new low water mark in 313.Va data . 314On return, 315.Va data 316contains the number of bytes of protocol data available to read. 317.Pp 318If the read direction of the socket has shutdown, then the filter 319also sets 320.Dv EV_EOF 321in 322.Va flags , 323and returns the socket error (if any) in 324.Va fflags . 325It is possible for EOF to be returned (indicating the connection is gone) 326while there is still data pending in the socket buffer. 327.It Vnodes 328Returns when the file pointer is not at the end of file. 329.Va data 330contains the offset from current position to end of file, 331and may be negative. 332.Pp 333This behavior is different from 334.Xr poll 2 , 335where read events are triggered for regular files unconditionally. 336This event can be triggered unconditionally by setting the 337.Dv NOTE_FILE_POLL 338flag in 339.Va fflags . 340.It "Fifos, Pipes" 341Returns when the there is data to read; 342.Va data 343contains the number of bytes available. 344.Pp 345When the last writer disconnects, the filter will set 346.Dv EV_EOF 347in 348.Va flags . 349This will be cleared by the filter when a new writer connects, 350at which point the 351filter will resume waiting for data to become available before 352returning. 353.It "BPF devices" 354Returns when the BPF buffer is full, the BPF timeout has expired, or 355when the BPF has 356.Dq immediate mode 357enabled and there is any data to read; 358.Va data 359contains the number of bytes available. 360.It Eventfds 361Returns when the counter is greater than 0; 362.Va data 363contains the counter value, which must be cast to 364.Vt uint64_t . 365.It Kqueues 366Returns when pending events are present on the queue; 367.Va data 368contains the number of events available. 369.El 370.It Dv EVFILT_WRITE 371Takes a descriptor as the identifier, and returns whenever 372it is possible to write to the descriptor. 373For sockets, pipes 374and fifos, 375.Va data 376will contain the amount of space remaining in the write buffer. 377The filter will set 378.Dv EV_EOF 379when the reader disconnects, and for the fifo case, this will be cleared 380when a new reader connects. 381Note that this filter is not supported for vnodes or BPF devices. 382.Pp 383For sockets, the low water mark and socket error handling is 384identical to the 385.Dv EVFILT_READ 386case. 387.Pp 388For eventfds, 389.Va data 390will contain the maximum value that can be added to the counter 391without blocking. 392.It Dv EVFILT_EMPTY 393Takes a descriptor as the identifier, and returns whenever 394there is no remaining data in the write buffer. 395.It Dv EVFILT_AIO 396Events for this filter are not registered with 397.Fn kevent 398directly but are registered via the 399.Va aio_sigevent 400member of an asynchronous I/O request when it is scheduled via an 401asynchronous I/O system call such as 402.Fn aio_read . 403The filter returns under the same conditions as 404.Fn aio_error . 405For more details on this filter see 406.Xr sigevent 3 and 407.Xr aio 4 . 408.It Dv EVFILT_VNODE 409Takes a file descriptor as the identifier and the events to watch for in 410.Va fflags , 411and returns when one or more of the requested events occurs on the descriptor. 412The events to monitor are: 413.Bl -tag -width "Dv NOTE_CLOSE_WRITE" 414.It Dv NOTE_ATTRIB 415The file referenced by the descriptor had its attributes changed. 416.It Dv NOTE_CLOSE 417A file descriptor referencing the monitored file, was closed. 418The closed file descriptor did not have write access. 419.It Dv NOTE_CLOSE_WRITE 420A file descriptor referencing the monitored file, was closed. 421The closed file descriptor had write access. 422.Pp 423This note, as well as 424.Dv NOTE_CLOSE , 425are not activated when files are closed forcibly by 426.Xr unmount 2 or 427.Xr revoke 2 . 428Instead, 429.Dv NOTE_REVOKE 430is sent for such events. 431.It Dv NOTE_DELETE 432The 433.Fn unlink 434system call was called on the file referenced by the descriptor. 435.It Dv NOTE_EXTEND 436For regular file, the file referenced by the descriptor was extended. 437.Pp 438For directory, reports that a directory entry was added or removed, 439as the result of rename operation. 440The 441.Dv NOTE_EXTEND 442event is not reported when a name is changed inside the directory. 443.It Dv NOTE_LINK 444The link count on the file changed. 445In particular, the 446.Dv NOTE_LINK 447event is reported if a subdirectory was created or deleted inside 448the directory referenced by the descriptor. 449.It Dv NOTE_OPEN 450The file referenced by the descriptor was opened. 451.It Dv NOTE_READ 452A read occurred on the file referenced by the descriptor. 453.It Dv NOTE_RENAME 454The file referenced by the descriptor was renamed. 455.It Dv NOTE_REVOKE 456Access to the file was revoked via 457.Xr revoke 2 458or the underlying file system was unmounted. 459.It Dv NOTE_WRITE 460A write occurred on the file referenced by the descriptor. 461.El 462.Pp 463On return, 464.Va fflags 465contains the events which triggered the filter. 466.It Dv EVFILT_PROC 467Takes the process ID to monitor as the identifier and the events to watch for 468in 469.Va fflags , 470and returns when the process performs one or more of the requested events. 471If a process can normally see another process, it can attach an event to it. 472The events to monitor are: 473.Bl -tag -width "Dv NOTE_TRACKERR" 474.It Dv NOTE_EXIT 475The process has exited. 476The exit status will be stored in 477.Va data . 478.It Dv NOTE_FORK 479The process has called 480.Fn fork . 481.It Dv NOTE_EXEC 482The process has executed a new process via 483.Xr execve 2 484or a similar call. 485.It Dv NOTE_TRACK 486Follow a process across 487.Fn fork 488calls. 489The parent process registers a new kevent to monitor the child process 490using the same 491.Va fflags 492as the original event. 493The child process will signal an event with 494.Dv NOTE_CHILD 495set in 496.Va fflags 497and the parent PID in 498.Va data . 499.Pp 500If the parent process fails to register a new kevent 501.Pq usually due to resource limitations , 502it will signal an event with 503.Dv NOTE_TRACKERR 504set in 505.Va fflags , 506and the child process will not signal a 507.Dv NOTE_CHILD 508event. 509.El 510.Pp 511On return, 512.Va fflags 513contains the events which triggered the filter. 514.It Dv EVFILT_PROCDESC 515Takes the process descriptor created by 516.Xr pdfork 2 517to monitor as the identifier and the events to watch for in 518.Va fflags , 519and returns when the associated process performs one or more of the 520requested events. 521The events to monitor are: 522.Bl -tag -width "Dv NOTE_EXIT" 523.It Dv NOTE_EXIT 524The process has exited. 525The exit status will be stored in 526.Va data . 527.El 528.Pp 529On return, 530.Va fflags 531contains the events which triggered the filter. 532.It Dv EVFILT_SIGNAL 533Takes the signal number to monitor as the identifier and returns 534when the given signal is delivered to the process. 535This coexists with the 536.Fn signal 537and 538.Fn sigaction 539facilities, and has a lower precedence. 540The filter will record 541all attempts to deliver a signal to a process, even if the signal has 542been marked as 543.Dv SIG_IGN , 544except for the 545.Dv SIGCHLD 546signal, which, if ignored, will not be recorded by the filter. 547Event notification happens after normal 548signal delivery processing. 549.Va data 550returns the number of times the signal has occurred since the last call to 551.Fn kevent . 552This filter automatically sets the 553.Dv EV_CLEAR 554flag internally. 555.It Dv EVFILT_TIMER 556Establishes an arbitrary timer identified by 557.Va ident . 558When adding a timer, 559.Va data 560specifies the moment to fire the timer (for 561.Dv NOTE_ABSTIME ) 562or the timeout period. 563The timer will be periodic unless 564.Dv EV_ONESHOT 565or 566.Dv NOTE_ABSTIME 567is specified. 568On return, 569.Va data 570contains the number of times the timeout has expired since the last call to 571.Fn kevent . 572For non-monotonic timers, this filter automatically sets the 573.Dv EV_CLEAR 574flag internally. 575.Pp 576The filter accepts the following flags in the 577.Va fflags 578argument: 579.Bl -tag -width "Dv NOTE_MSECONDS" 580.It Dv NOTE_SECONDS 581.Va data 582is in seconds. 583.It Dv NOTE_MSECONDS 584.Va data 585is in milliseconds. 586.It Dv NOTE_USECONDS 587.Va data 588is in microseconds. 589.It Dv NOTE_NSECONDS 590.Va data 591is in nanoseconds. 592.It Dv NOTE_ABSTIME 593The specified expiration time is absolute. 594.El 595.Pp 596If 597.Va fflags 598is not set, the default is milliseconds. 599On return, 600.Va fflags 601contains the events which triggered the filter. 602.Pp 603Periodic timers with a specified timeout of 0 will be silently adjusted to 604timeout after 1 of the time units specified by the requested precision in 605.Va fflags . 606If an absolute time is specified that has already passed, then it is treated as 607if the current time were specified and the event will fire as soon as possible. 608.Pp 609If an existing timer is re-added, the existing timer will be 610effectively canceled (throwing away any undelivered record of previous 611timer expiration) and re-started using the new parameters contained in 612.Va data 613and 614.Va fflags . 615.Pp 616There is a system wide limit on the number of timers 617which is controlled by the 618.Va kern.kq_calloutmax 619sysctl. 620.It Dv EVFILT_USER 621Establishes a user event identified by 622.Va ident 623which is not associated with any kernel mechanism but is triggered by 624user level code. 625The lower 24 bits of the 626.Va fflags 627may be used for user defined flags and manipulated using the following: 628.Bl -tag -width "Dv NOTE_FFLAGSMASK" 629.It Dv NOTE_FFNOP 630Ignore the input 631.Va fflags . 632.It Dv NOTE_FFAND 633Bitwise AND 634.Va fflags . 635.It Dv NOTE_FFOR 636Bitwise OR 637.Va fflags . 638.It Dv NOTE_FFCOPY 639Copy 640.Va fflags . 641.It Dv NOTE_FFCTRLMASK 642Control mask for 643.Va fflags . 644.It Dv NOTE_FFLAGSMASK 645User defined flag mask for 646.Va fflags . 647.El 648.Pp 649A user event is triggered for output with the following: 650.Bl -tag -width "Dv NOTE_FFLAGSMASK" 651.It Dv NOTE_TRIGGER 652Cause the event to be triggered. 653.El 654.Pp 655On return, 656.Va fflags 657contains the users defined flags in the lower 24 bits. 658.El 659.Sh CANCELLATION BEHAVIOUR 660If 661.Fa nevents 662is non-zero, i.e., the function is potentially blocking, the call 663is a cancellation point. 664Otherwise, i.e., if 665.Fa nevents 666is zero, the call is not cancellable. 667Cancellation can only occur before any changes are made to the kqueue, 668or when the call was blocked and no changes to the queue were requested. 669.Sh RETURN VALUES 670The 671.Fn kqueue 672system call 673creates a new kernel event queue and returns a file descriptor. 674If there was an error creating the kernel event queue, a value of -1 is 675returned and errno set. 676.Pp 677The 678.Fn kevent 679system call 680returns the number of events placed in the 681.Fa eventlist , 682up to the value given by 683.Fa nevents . 684If an error occurs while processing an element of the 685.Fa changelist 686and there is enough room in the 687.Fa eventlist , 688then the event will be placed in the 689.Fa eventlist 690with 691.Dv EV_ERROR 692set in 693.Va flags 694and the system error in 695.Va data . 696Otherwise, 697.Dv -1 698will be returned, and 699.Dv errno 700will be set to indicate the error condition. 701If the time limit expires, then 702.Fn kevent 703returns 0. 704.Sh EXAMPLES 705.Bd -literal -compact 706#include <sys/event.h> 707#include <err.h> 708#include <fcntl.h> 709#include <stdio.h> 710#include <stdlib.h> 711#include <string.h> 712 713int 714main(int argc, char **argv) 715{ 716 struct kevent event; /* Event we want to monitor */ 717 struct kevent tevent; /* Event triggered */ 718 int kq, fd, ret; 719 720 if (argc != 2) 721 err(EXIT_FAILURE, "Usage: %s path\en", argv[0]); 722 fd = open(argv[1], O_RDONLY); 723 if (fd == -1) 724 err(EXIT_FAILURE, "Failed to open '%s'", argv[1]); 725 726 /* Create kqueue. */ 727 kq = kqueue(); 728 if (kq == -1) 729 err(EXIT_FAILURE, "kqueue() failed"); 730 731 /* Initialize kevent structure. */ 732 EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE, 733 0, NULL); 734 /* Attach event to the kqueue. */ 735 ret = kevent(kq, &event, 1, NULL, 0, NULL); 736 if (ret == -1) 737 err(EXIT_FAILURE, "kevent register"); 738 if (event.flags & EV_ERROR) 739 errx(EXIT_FAILURE, "Event error: %s", strerror(event.data)); 740 741 for (;;) { 742 /* Sleep until something happens. */ 743 ret = kevent(kq, NULL, 0, &tevent, 1, NULL); 744 if (ret == -1) { 745 err(EXIT_FAILURE, "kevent wait"); 746 } else if (ret > 0) { 747 printf("Something was written in '%s'\en", argv[1]); 748 } 749 } 750} 751.Ed 752.Sh ERRORS 753The 754.Fn kqueue 755system call fails if: 756.Bl -tag -width Er 757.It Bq Er ENOMEM 758The kernel failed to allocate enough memory for the kernel queue. 759.It Bq Er ENOMEM 760The 761.Dv RLIMIT_KQUEUES 762rlimit 763(see 764.Xr getrlimit 2 ) 765for the current user would be exceeded. 766.It Bq Er EMFILE 767The per-process descriptor table is full. 768.It Bq Er ENFILE 769The system file table is full. 770.El 771.Pp 772The 773.Fn kevent 774system call fails if: 775.Bl -tag -width Er 776.It Bq Er EACCES 777The process does not have permission to register a filter. 778.It Bq Er EFAULT 779There was an error reading or writing the 780.Va kevent 781structure. 782.It Bq Er EBADF 783The specified descriptor is invalid. 784.It Bq Er EINTR 785A signal was delivered before the timeout expired and before any 786events were placed on the kqueue for return. 787.It Bq Er EINTR 788A cancellation request was delivered to the thread, but not yet handled. 789.It Bq Er EINVAL 790The specified time limit or filter is invalid. 791.It Bq Er EINVAL 792The specified length of the event or change lists is negative. 793.It Bq Er ENOENT 794The event could not be found to be modified or deleted. 795.It Bq Er ENOMEM 796No memory was available to register the event 797or, in the special case of a timer, the maximum number of 798timers has been exceeded. 799This maximum is configurable via the 800.Va kern.kq_calloutmax 801sysctl. 802.It Bq Er ESRCH 803The specified process to attach to does not exist. 804.El 805.Pp 806When 807.Fn kevent 808call fails with 809.Er EINTR 810error, all changes in the 811.Fa changelist 812have been applied. 813.Sh SEE ALSO 814.Xr aio_error 2 , 815.Xr aio_read 2 , 816.Xr aio_return 2 , 817.Xr poll 2 , 818.Xr read 2 , 819.Xr select 2 , 820.Xr sigaction 2 , 821.Xr write 2 , 822.Xr pthread_setcancelstate 3 , 823.Xr signal 3 824.Rs 825.%A Jonathan Lemon 826.%T "Kqueue: A Generic and Scalable Event Notification Facility" 827.%I USENIX Association 828.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference 829.%D June 25-30, 2001 830.\".http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf 831.Re 832.Sh HISTORY 833The 834.Fn kqueue 835and 836.Fn kevent 837system calls first appeared in 838.Fx 4.1 . 839.Sh AUTHORS 840The 841.Fn kqueue 842system and this manual page were written by 843.An Jonathan Lemon Aq Mt [email protected] . 844.Sh BUGS 845The 846.Fa timeout 847value is limited to 24 hours; longer timeouts will be silently 848reinterpreted as 24 hours. 849.Pp 850In versions older than 851.Fx 12.0 , 852.In sys/event.h 853failed to parse without including 854.In sys/types.h 855manually. 856