Number of kevents registered in kqueue

Václav Haisman V.Haisman at sh.cvut.cz
Fri Dec 16 14:37:12 PST 2005



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.
> 
> Also, I recommend that the man page mention that a kqueue may be
> close(2)'d.  The only reference that it can be is that the manual page
> says the kqueue() call returns a descriptor.
> 
> Seán
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."


Vaclav Haisman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 546 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20051216/c93a5f86/signature.bin


More information about the freebsd-hackers mailing list