Number of kevents registered in kqueue

Seán C. Farley sean-freebsd at farley.org
Fri Dec 16 14:55:51 PST 2005


On Fri, 16 Dec 2005, Dan Nelson wrote:

> In the last episode (Dec 16), Sen C. Farley said:
>> I may have missed it in the man page, but I am unable to find a way
>> to determine how many kevents are currently registered within a
>> kqueue.  If there is no method for a count, how about a way to find
>> if a kqueue is empty or not.  Besides tracking what events are still
>> within a kqueue, this would make for an easier way to write an event
>> loop.  Currently, calling kevent() on an empty kqueue will still
>> block.
>
> I don't think there's a way currently.  What I did in my local tree is
> modify kern_kevent so that if the magic number -1 is passed in as
> nchanges, it will return the entire queued event list back to the
> caller in *eventlist, and return the number of events as the
> returncode.  Very useful for debugging kqueue-using programs where you
> want to compare what you think you're waiting for, and what the kernel
> thinks you're waiting for :)

Why does this pop in my mind when reading your reply?  :)
Lt. Saavik:  You lied.
Spock:       I exaggerated.

In other words, there does not currently exist a method to does this on
a vanilla system.  I can deal with that.  It still would be a nice
feature to have.

Seán
-- 
sean-freebsd at farley.org


More information about the freebsd-hackers mailing list