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

kqueues for Signal Handling

Unix signals, due to their asynchronous nature, are difficult to handle correctly. Race conditions are possible, plus you have to be aware of functions you can or can’t call at signal interrupt time. Most of the time, you really do not have to handle a signal the instant it is delivered. You can handle it later at a more convenient time. That is why a common signal handling technique is to set a global variable and then check it later.

You can use kqueues and kevent() to handle signals, saving you from the headaches caused by the signal handling API. The filter for signals is also one of the simplest of the kqueue filters.

kqueue event handling can be used in tandem with the classic signal handling API. Calls like ...

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