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 <kzak@redhat.com>
# define SCHED_FLAG_RESET_ON_FORK 0x01
#endif
-#if defined (__linux__) && !defined(HAVE_SCHED_SETATTR)
+#if defined (__linux__)
# include <sys/syscall.h>
#endif
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
}