You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Non-Compliant Coding Example

#include <signal.h>

size_t i;

void handler(void) {
   i = 0;
}

int main(void) {
   signal(SIGINT, handler);

   i = 1;

   while(i) {
      /* do something */
   }
}

Compliant Solution


Risk Assessment

In addition to incorrect optimizations, this can cause race conditions, resulting in inconsistent state.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

SIGxx-C

2 (medium)

2 (probable)

3 (low)

P12

L2

References

[[ISO/IEC 03]] "Signals and Interrupts"
[[Open Group 04]] longjmp
[OpenBSD] signal() Man Page

  • No labels