MCPcopy Create free account
hub / github.com/pybind/pybind11 / termination_signal_handler

Function termination_signal_handler

tests/test_with_catch/catch.cpp:129–137  ·  view source on GitHub ↗

Signal handler to print a message when the process is terminated. Uses only async-signal-safe functions.

Source from the content-addressed store, hash-verified

127// Signal handler to print a message when the process is terminated.
128// Uses only async-signal-safe functions.
129void 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected