MCPcopy Create free account
hub / github.com/DFHack/dfhack / handle_signal_internal

Function handle_signal_internal

library/Crashlog.cpp:47–64  ·  view source on GitHub ↗

Force this method to be inlined so that it doesn't create a stack frame

Source from the content-addressed store, hash-verified

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
66extern "C" void dfhack_crashlog_handle_signal(int sig) {
67 handle_signal_internal(sig);

Callers 2

Calls 3

flag_setFunction · 0.85
readFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected