fix a segfault on signals received after main returns
The waybar process does not exit instantaneously. Signals may be recevied after main has started freeing resources. When a worker thread is in `fgets` this time window can last forever. An easy way to duplicate the crash is pressing ^C twice with a Hyprland module. Thread 1 "waybar" received signal SIGSEGV, Segmentation fault. spdlog::sinks::sink::should_log (this=0x5f620b542ca5, msg_level=spdlog::level::info) at /usr/src/debug/spdlog/spdlog-1.14.1/include/spdlog/sinks/sink-inl.h:13 13 return msg_level >= level_.load(std::memory_order_relaxed); (gdb) p $_siginfo._sifields._sigfault.si_addr $1 = (void *) 0x5f620b542cad
This commit is contained in:
@ -107,6 +107,10 @@ int main(int argc, char* argv[]) {
|
||||
ret = client->main(argc, argv);
|
||||
} while (reload);
|
||||
|
||||
std::signal(SIGUSR1, SIG_IGN);
|
||||
std::signal(SIGUSR2, SIG_IGN);
|
||||
std::signal(SIGINT, SIG_IGN);
|
||||
|
||||
delete client;
|
||||
return ret;
|
||||
} catch (const std::exception& e) {
|
||||
|
Reference in New Issue
Block a user