MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / setSignalHandler

Function setSignalHandler

oneflow/api/python/utils/dataloader.cpp:58–68  ·  view source on GitHub ↗

signal(2) is really not portable. So use sigaction. http://man7.org/linux/man-pages/man2/signal.2.html

Source from the content-addressed store, hash-verified

56// signal(2) is really not portable. So use sigaction.
57// http://man7.org/linux/man-pages/man2/signal.2.html
58static inline void setSignalHandler(int signal, void (*handler)(int, siginfo_t*, void*),
59 struct sigaction* old_sa_ptr) {
60 struct sigaction sa {};
61 sa.sa_sigaction = handler;
62 sa.sa_flags = SA_RESTART | SA_SIGINFO | SA_NOCLDSTOP | SA_NODEFER;
63 if (sigemptyset(&sa.sa_mask) != 0 || sigaction(signal, &sa, old_sa_ptr) != 0) {
64 std::ostringstream oss;
65 oss << "An error occurred while setting handler for " << strsignal(signal) << ".";
66 throw std::runtime_error(oss.str());
67 }
68}
69
70SIGNAL_HANDLER(SIGBUS, handler_SIGBUS,
71 "ERROR: Unexpected bus error encountered in worker. "

Callers 1

Calls 1

sigactionClass · 0.70

Tested by

no test coverage detected