Skip to content

Commit

Permalink
core: don't check RLIMIT_RTPRIO
Browse files Browse the repository at this point in the history
FreeBSD doesn't have RLIMIT_RTPRIO. So instead we skip this check and
just always try to set our priority to the lowest SCHED_RR priority
available.

Fixes #1082

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Jun 24, 2023
1 parent b852723 commit 9295f7e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,11 +2577,8 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
return NULL;
}
void set_rr_scheduling(void) {
struct rlimit rlim;
if (getrlimit(RLIMIT_RTPRIO, &rlim) != 0) {
log_warn("Failed to get RLIMIT_RTPRIO, not setting real-time priority");
return;
}
int priority = sched_get_priority_min(SCHED_RR);

int old_policy;
int ret;
struct sched_param param;
Expand All @@ -2592,14 +2589,15 @@ void set_rr_scheduling(void) {
return;
}

param.sched_priority = (int)rlim.rlim_cur;

param.sched_priority = priority;
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
if (ret != 0) {
log_info("Failed to set scheduling priority to %lu", rlim.rlim_cur);
log_info("Failed to set real-time scheduling priority to %d. Consider "
"giving picom the CAP_SYS_NICE capability",
priority);
return;
}
log_info("Set scheduling priority to %lu", rlim.rlim_cur);
log_info("Set real-time scheduling priority to %d", priority);
}

/**
Expand Down

0 comments on commit 9295f7e

Please sign in to comment.