mirror of
https://github.com/hyprwm/Hyprland
synced 2026-04-19 00:20:37 +02:00
This adds a .clang-tidy file for us. It's not a strict requirement to be compliant, but I tuned it to be alright.
29 lines
No EOL
899 B
C++
29 lines
No EOL
899 B
C++
#include "initHelpers.hpp"
|
|
|
|
bool NInit::isSudo() {
|
|
return getuid() != geteuid() || !geteuid();
|
|
}
|
|
|
|
void NInit::gainRealTime() {
|
|
const int minPrio = sched_get_priority_min(SCHED_RR);
|
|
int old_policy;
|
|
struct sched_param param;
|
|
|
|
if (pthread_getschedparam(pthread_self(), &old_policy, ¶m)) {
|
|
Debug::log(WARN, "Failed to get old pthread scheduling priority");
|
|
return;
|
|
}
|
|
|
|
param.sched_priority = minPrio;
|
|
|
|
if (pthread_setschedparam(pthread_self(), SCHED_RR, ¶m)) {
|
|
Debug::log(WARN, "Failed to change process scheduling strategy");
|
|
return;
|
|
}
|
|
|
|
pthread_atfork(nullptr, nullptr, []() {
|
|
const struct sched_param param = {.sched_priority = 0};
|
|
if (pthread_setschedparam(pthread_self(), SCHED_OTHER, ¶m))
|
|
Debug::log(WARN, "Failed to reset process scheduling strategy");
|
|
});
|
|
} |