Signal handler to print a message when the process is terminated. Uses only async-signal-safe functions.
| 127 | // Signal handler to print a message when the process is terminated. |
| 128 | // Uses only async-signal-safe functions. |
| 129 | void termination_signal_handler(int sig) { |
| 130 | const char *msg = "[ SIGNAL ] Process received SIGTERM\n"; |
| 131 | // write() is async-signal-safe, unlike std::cout |
| 132 | ssize_t written = write(STDOUT_FILENO, msg, strlen(msg)); |
| 133 | (void) written; // suppress "unused variable" warnings |
| 134 | // Re-raise with default handler to get proper exit status |
| 135 | std::signal(sig, SIG_DFL); |
| 136 | std::raise(sig); |
| 137 | } |
| 138 | #endif |
| 139 | |
| 140 | } // namespace |
nothing calls this directly
no outgoing calls
no test coverage detected