1.\" $NetBSD: knote.9,v 1.11 2004/02/18 16:50:25 jdolecek Exp $ 2.\" 3.\" Copyright (c) 2001, 2002, 2003 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This documentation is derived from text contributed by 7.\" Luke Mewburn. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd February 18, 2004 38.Dt KNOTE 9 39.Os 40.Sh NAME 41.Nm knote , 42.Nm KNOTE 43.Nd raise kernel event 44.Sh SYNOPSIS 45.In sys/event.h 46.Ft void 47.Fn knote "struct klist *list" "long hint" 48.Fn KNOTE "struct klist *list" "long hint" 49.Sh DESCRIPTION 50The 51.Fn knote 52function provides a hook into the kqueue kernel event notification 53mechanism to allow sections of the kernel to raise a kernel event 54in the form of a 55.Sq knote , 56which is a 57.Fa struct knote 58as defined in 59.Aq Pa sys/event.h . 60.Pp 61.Fn knote 62takes a singly linked 63.Fa list 64of knotes, along with a 65.Fa hint 66(which is passed to the appropriate filter routine). 67.Fn knote 68then walks the 69.Fa list 70making calls to the filter routine for each knote. 71As each knote contains a reference to the data structure that it is 72attached to, the filter may choose to examine the data structure in 73deciding whether an event should be reported. 74The 75.Fa hint 76is used to pass in additional information, which may not be present in 77the data structure that the filter examines. 78.Pp 79If the filter decides that the event should be returned, it returns a 80non-zero value and 81.Fn knote 82links the knote onto the tail end of the active list in the 83corresponding kqueue for the application to retrieve. 84If the knote is already on the active list, no action is taken, but the 85call to the filter occurs in order to provide an opportunity for the 86filter to record the activity. 87.Pp 88.Fn knote 89must not be called from interrupt contexts running at an interrupt 90priority level higher than 91.Fn splsched . 92.Pp 93.Fn KNOTE 94is a macro that calls 95.Fn knote list hint 96if 97.Fa list 98is not empty. 99.\" .Sh ERRORS 100.Sh SEE ALSO 101.Xr kqueue 2 , 102.Xr kfilter_register 9 103.Sh HISTORY 104The 105.Fn knote 106and 107.Fn KNOTE 108functions first appeared in 109.Fx 4.1 , 110and then in 111.Nx 2.0 . 112.Sh AUTHORS 113The 114.Fn kqueue 115system was written by 116.An Jonathan Lemon Aq jlemon@FreeBSD.org . 117