From: jonnyh64 <60403537+jonnyh64@users.noreply.github.com> Date: Wed, 29 Jan 2020 21:24:16 +0000 (+0100) Subject: chrt: Use sched_setscheduler system call directly X-Git-Tag: v2.36-rc1~242 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fcc3078754291d2f5121797eb91b364f8e24b2f1;p=thirdparty%2Futil-linux.git chrt: Use sched_setscheduler system call directly musl libc does not support the sched_setscheduler library function because the underlying Linux system call does not confirm to Posix; this patch makes chrt use the system call directly [kzak@redhat.com: - note that musl libc implements sched_setscheduler() but returns -ENOSYS all time... - add ifdefs to the patch - make sure we include syscall.h] References: http://git.musl-libc.org/cgit/musl/commit/src/sched/sched_setscheduler.c?id=1e21e78bf7a5c24c217446d8760be7b7188711c2 Addresses: https://github.com/karelzak/util-linux/issues/943 Signed-off-by: Karel Zak --- diff --git a/schedutils/chrt.c b/schedutils/chrt.c index cc3a8c2f0e..299c99221e 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -60,7 +60,7 @@ # define SCHED_FLAG_RESET_ON_FORK 0x01 #endif -#if defined (__linux__) && !defined(HAVE_SCHED_SETATTR) +#if defined (__linux__) # include #endif @@ -347,7 +347,16 @@ static int set_sched_one_by_setscheduler(struct chrt_ctl *ctl, pid_t pid) if (ctl->reset_on_fork) policy |= SCHED_RESET_ON_FORK; # endif + +#if defined (__linux__) && defined(SYS_sched_setscheduler) + /* musl libc returns ENOSYS for its sched_setscheduler library + * function, because the sched_setscheduler Linux kernel system call + * does not conform to Posix; so we use the system call directly + */ + return syscall(SYS_sched_setscheduler, pid, policy, &sp); +#else return sched_setscheduler(pid, policy, &sp); +#endif }