Controlling Signals

The previous sections demonstrate how you can define actions for signals and process them within your programs. Sometimes it is necessary to control more closely when a signal is allowed to be raised. The following sections will show you how this is accomplished under UNIX.

Blocking Signals

When the sigaction(2) function was discussed, it was noted that certain signals could be blocked during the call to the signal handler. For example, when SIGINT is handled by the signal handler, further SIGINT signals are prevented from taking place until the present handler returns (unless flag SA_NOMASK or SA_NODEFER is used).

In a similar fashion, your application can enter a critical piece of code where signals could cause it problems. ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.