mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-23 23:29:49 +01:00
df06cb4d71
* CrashReporter: restore explicit environ(7) after 8bbeee1173
BSD systems don't declare environ(7) in any header like POSIX suggests.
src/signal-safe.cpp:12:23: error: use of undeclared identifier 'environ'
12 | for (char** var = environ; *var != nullptr; var++) {
| ^
* fix
---------
Co-authored-by: Vaxry <vaxry@vaxry.net>
32 lines
662 B
C++
32 lines
662 B
C++
#include "signal-safe.hpp"
|
|
|
|
#ifndef __GLIBC__
|
|
#include <signal.h>
|
|
#endif
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <cstring>
|
|
|
|
// NOLINTNEXTLINE
|
|
extern "C" char** environ;
|
|
|
|
//
|
|
char const* sigGetenv(char const* name) {
|
|
const size_t len = strlen(name);
|
|
for (char** var = environ; *var != nullptr; var++) {
|
|
if (strncmp(*var, name, len) == 0 && (*var)[len] == '=') {
|
|
return (*var) + len + 1;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
char const* sigStrsignal(int sig) {
|
|
#ifdef __GLIBC__
|
|
return sigabbrev_np(sig);
|
|
#elif defined(__DragonFly__) || defined(__FreeBSD__)
|
|
return sys_signame[sig];
|
|
#else
|
|
return "unknown";
|
|
#endif
|
|
}
|