Force this method to be inlined so that it doesn't create a stack frame
| 45 | |
| 46 | // Force this method to be inlined so that it doesn't create a stack frame |
| 47 | [[gnu::always_inline]] inline void handle_signal_internal(int sig) { |
| 48 | if (shutdown.load() || crashed.exchange(true) || crashlog_ready.load()) { |
| 49 | // Ensure the signal handler doesn't try to write a crashlog |
| 50 | // whilst the crashlog thread is unavailable. |
| 51 | std::quick_exit(1); |
| 52 | } |
| 53 | crash_info.signal = sig; |
| 54 | crash_info.backtrace_entries = backtrace(crash_info.backtrace, BT_ENTRY_MAX); |
| 55 | |
| 56 | // Signal saving of crashlog |
| 57 | flag_set(crashlog_ready); |
| 58 | // Wait for completion via eventfd read, if fd isn't valid, bail |
| 59 | if (crashlog_complete != -1) { |
| 60 | [[maybe_unused]] uint64_t v; |
| 61 | [[maybe_unused]] auto _ = read(crashlog_complete, &v, sizeof(v)); |
| 62 | } |
| 63 | std::quick_exit(1); |
| 64 | } |
| 65 | |
| 66 | extern "C" void dfhack_crashlog_handle_signal(int sig) { |
| 67 | handle_signal_internal(sig); |
no test coverage detected