signal(2) is really not portable. So use sigaction. http://man7.org/linux/man-pages/man2/signal.2.html
| 56 | // signal(2) is really not portable. So use sigaction. |
| 57 | // http://man7.org/linux/man-pages/man2/signal.2.html |
| 58 | static 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 | |
| 70 | SIGNAL_HANDLER(SIGBUS, handler_SIGBUS, |
| 71 | "ERROR: Unexpected bus error encountered in worker. " |
no test coverage detected