O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Registering and Handling Events

kevent() registers your interest in specific filters and events with a kqueue, and it is also the function used to block on a kqueue waiting for event notifications. The signature of kevent() is a bit long because it lets you do both operations at the same time.

int kevent (int kqueue,
            const struct kevent *changeList, int numChanges,
                  struct kevent *eventList,  int numEvents,
            const struct timespec *timeout);

The first argument to kevent() is the kqueue you want to manipulate. changeList holds the set of new events for the kqueue to monitor, as well as any changes to events the kqueue is already monitoring. If changeList is non-NULL and numChanges is greater than zero, then the events in changeList will be applied ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required