quill
quill copied to clipboard
Call LOG_BACKTRACE in signal handler
Is it safe (i.e. defined behavior) to use LOG_BACKTRACE in a signal handler? It would even make sense to have a flag to log a backtrace, when receiving a SIGSEV. With c++17 the restrictions for signal handlers are a bit more relaxed, but I'm unsure, whether it is safe. Nonetheless, a statement about this in the documentation would be helpful.
Sorry for the late response.
I am not sure to answer 100% but I am quite confident that it will be fine.
LOG_INFO
macros are called inside the signal handler without any issues. LOG_BACKTRACE
doesn't do many more things, when the log message is received by the backend thread it will be stored in a buffer and will be latter on logged only if certain criteria are met.
However, I don't know how useful it would be to use LOG_BACKTRACE
when you receive a SIGSEV. In that care most programs will probably want to LOG something immediately and then terminate.