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
signature.asc
Description: OpenPGP digital signature

