Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Vulnerabilities can arise if a non-asynchronous-safe signal handler is interrupted with any unmasked signal, including its own, especially if it manipulates globally accessible data.

Non-Compliant Code Example

This non-compliant code example registers a single signal handler to process both SIGUSR1 and SIGUSR2. The variable sig2 should be set to one if one or more SIGUSR1 signals are followed by SIGUSR2. This code , essentially implements implementing a finite state machine within the signal handler.

...

Unfortunately, there is a race condition in the implementation of handler(). If handler() is called to handle SIGUSR1 and is interrupted to handle SIGUSR2, it is possible that sig2 will not be set.This non-compliant code example also violates SIG31-C. Do not access or modify shared objects in signal handlers.

Compliant Solution (POSIX)

...