Skip to content

Commit

Permalink
start-stop-daemon: fix setting scheduler with musl
Browse files Browse the repository at this point in the history
musl sched_setscheduler() is only a stub in musl and the glibc
implementation does "the wrong thing". Use pthread_setschedparam
instead.

ref: https://www.openwall.com/lists/musl/2016/03/01/5
fixes: #689
  • Loading branch information
ncopa committed Feb 2, 2024
1 parent c45fe9f commit f5f55cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/start-stop-daemon/start-stop-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <getopt.h>
#include <limits.h>
#include <grp.h>
#include <pthread.h>
#include <pwd.h>
#include <sched.h>
#include <signal.h>
Expand Down Expand Up @@ -1123,7 +1124,7 @@ int main(int argc, char **argv)
if (sched_prio == -1)
sched.sched_priority = sched_get_priority_min(scheduler_index);

if (sched_setscheduler(mypid, scheduler_index, &sched))
if (pthread_setschedparam(pthread_self(), scheduler_index, &sched))
eerrorx("Failed to set scheduler: %s", strerror(errno));
} else if (sched_prio != -1) {
const struct sched_param sched = {.sched_priority = sched_prio};
Expand Down

0 comments on commit f5f55cf

Please sign in to comment.