[metadata]
id = "CON37-C"
type = "recommendation"
category = "CON"
number = 37
title = "Do not call signal() in a multithreaded program"
description = """
Calling thesignal()function in a multithreaded program isundefined behavior.
(Seeundefined behavior 135.) This noncompliant code example invokes
thesignal()function from a multithreaded program: #include <signal.h> #include
<stddef.h> #include <threads.h> volatile sig_atomic_t flag = 0; void handler(int
signum) { flag = 1; } /* Runs until user sends SIGUSR1 */ int func(void *data) {
while (!flag) { /* ... */ } return 0; } int main(void) { signal(SIGUSR1,
handler); /* Undefined behavior */ thrd_t tid; if (thrd_success !=
thrd_create(&tid, func, NULL)) { /* Handle error */ } /* ... */ return 0; }
"""
severity = "Low"
likelihood = "Probable"
priority = "P4"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 06, 2025"
[rules.cert_c.CON37-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/CON37-C.+Do+not+call+signal%28%29+in+a+multithreaded+program"