Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/unixsignals.cpp: fix signal handler
Fix two issues in the signal handler function: * Use `volatile std::sig_atomic_t` for the variable that will be written to the socket. See https://en.cppreference.com/w/cpp/utility/program/sig_atomic_t and https://en.cppreference.com/w/cpp/utility/program/signal * Don't try to print anything to the log or the console in the signal handler. We were calling `qDebug()` which seems convenient for debugging the signal handler, however, `qDebug()` calls `gettimeofday()`, which is not signal safe. The list of signal safe functions is here: https://pubs.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_04.html#tag_02_04_01 which notably does _not_ include `gettimeofday()`. Unfortunately there is virtually no way to log something safely from inside a signal handler itself. We can log stuff once we've passed it along via Qt Signals and Slots, but not inside the OS signal handler itself. Also see https://stackoverflow.com/questions/53155166/is-gettimeofday-async-signal-safe-and-can-it-cause-deadlock-if-used-in-signal and https://man7.org/linux/man-pages/man7/signal-safety.7.html
- Loading branch information