Versions Compared

Key

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

...

Improper handling of signals can lead to security vulnerabilities. The following rules and recommendations are designed to reduce the common errors associated with signal handling.

Implementation Details

It is important to note that the signal function behaves a little differently in Windows than it does on Linux/BSD systems. When a signal handler is installed with the signal function in Windows, after the signal is triggered once, the default action is restored for that signal. Conversely, Linux/BSD systems leave the signal handler defined by the user in place until it is explicitly removed. If you desire this latter behavior on a Windows system, a standards-compliant solution is to rebind the signal to the handler in the first line of the handler itself:

Code Block

void handler(int signum) {
   signal(signum, handler);

   /* rest of handling code */
}

Rules

SIG30-C. Only call asynchronous-safe functions within signal handlers

...