...
This compliant solution defines sig_handler()
as having C language linkage. Note that this solution requires all signal handler functions to be declared with external linkage instead of As a consequence of declaring the signal handler with C language linkage, the signal handler will have external linkage rather than internal linkage.
Code Block | ||||
---|---|---|---|---|
| ||||
#include <csignal> extern "C" void sig_handler(int sig) { // Implementation details elided } void f() { if (SIG_ERR == std::signal(SIGTERM, sig_handler)) { // Handle error } } |
...