Number of kevents registered in kqueue

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


On Fri, 16 Dec 2005, Václav Haisman wrote:

> Seán C. Farley wrote:
>> 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.

<snip>

> I was working with it recently and my understanding is that if you
> want to retrieve any events and not block if there are none then you
> should give it zeroed struct timespec. Quote from the man page:
>
> "If timeout is a NULL pointer, kevent() waits indefinitely.  To effect
> a poll, the timeout argument should be non-NULL, pointing to a
> zero-valued timespec structure."

I understand about the timeout.  I am looking for different methods to
break out of a loop where I want to remain until all events are handled
and deleted from the kqueue.

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


More information about the freebsd-hackers mailing list