mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 14:45:58 +01:00
90a53aed59
`CrashReporter::createAndSaveCrash()` is not async-signal-safe, resulting in random deadlocks/double-crashes during Hyprland crashes. This changes the function to be (mostly) async-signal-safe.
30 lines
627 B
C++
30 lines
627 B
C++
#include "signal-safe.hpp"
|
|
|
|
#ifndef __GLIBC__
|
|
#include <signal.h>
|
|
#endif
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
extern char** environ;
|
|
|
|
char const* sig_getenv(char const* name) {
|
|
int len = strlen(name);
|
|
for (char** var = environ; *var != NULL; var++) {
|
|
if (strncmp(*var, name, len) == 0 && (*var)[len] == '=') {
|
|
return (*var) + len + 1;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
char const* sig_strsignal(int sig) {
|
|
#ifdef __GLIBC__
|
|
return sigabbrev_np(sig);
|
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
|
return sys_signame[sig];
|
|
#else
|
|
return "unknown";
|
|
#endif
|
|
}
|