Skip to main content

IAR Embedded Workbench for RISC-V 3.40

CERT-SIG34-C

In this section:
Synopsis

Do not call signal() from within interruptible signal handlers.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

A signal handler should not reassert its desire to handle its own signal.

Coding standards
CERT SIG34-C

Do not call signal() from within interruptible signal handlers

Code examples

The following code example fails the check and will give a warning:

#include <signal.h>

void handler(int signum) {
  if (signal(signum, handler) == SIG_ERR) {
    /* Handle error */
  }
  /* Handle signal */
}

void func(void) {
  if (signal(SIGABRT, handler) == SIG_ERR) {
    /* Handle error */
  }
}

The following code example passes the check and will not give a warning about this issue:

#include <signal.h>

void handler(int signum) {
  /* Handle signal */
}

void func(void) {
  if (signal(SIGABRT, handler) == SIG_ERR) {
    /* Handle error */
  }
}