From 9860a34e3cca46d61ad172554c7c2af172d7bf00 Mon Sep 17 00:00:00 2001 From: psykose Date: Fri, 5 Jul 2024 18:05:33 +0200 Subject: [PATCH] utils: make setting/restoring from RT thread work on musl musl no-ops sched_setscheduler, pthread_setschedparam should work everywhere --- src/Utils/Process.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Utils/Process.cpp b/src/Utils/Process.cpp index 7f6b6d5528..e71786f757 100644 --- a/src/Utils/Process.cpp +++ b/src/Utils/Process.cpp @@ -18,6 +18,7 @@ #include #endif +#include #include #include #include @@ -472,7 +473,7 @@ namespace gamescope::Process struct sched_param newSched{}; sched_getparam( 0, &newSched ); newSched.sched_priority = sched_get_priority_min( SCHED_RR ); - if ( sched_setscheduler( 0, SCHED_RR, &newSched ) ) + if ( pthread_setschedparam( pthread_self(), SCHED_RR, &newSched ) ) { s_ProcessLog.errorf_errno( "Failed to set realtime scheduling." ); return false; @@ -491,7 +492,7 @@ namespace gamescope::Process if ( !g_oOldSchedulerInfo ) return; - if ( sched_setscheduler( 0, g_oOldSchedulerInfo->nPolicy, &g_oOldSchedulerInfo->SchedParam ) ) + if ( pthread_setschedparam( pthread_self(), g_oOldSchedulerInfo->nPolicy, &g_oOldSchedulerInfo->SchedParam ) ) { s_ProcessLog.errorf_errno( "Failed to restore from realtime scheduling." ); return; @@ -506,4 +507,4 @@ namespace gamescope::Process return __progname; } -} \ No newline at end of file +}