From 96d729bc00a13a0c870701262745209e1ad59456 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 27 Nov 2024 16:39:37 +0100 Subject: [PATCH] Cygwin: sched_setscheduler: allow changes of the priority Behave like sched_setparam() if the requested policy is identical to the fixed value (SCHED_FIFO) returned by sched_getscheduler(). Fixes: 9a08b2c02eea ("* sched.cc: New file. Implement sched*.") Signed-off-by: Christian Franke (cherry picked from commit 522f3e921aa034c6a146021a918ce8b479a9111e) --- winsup/cygwin/release/3.5.5 | 3 +++ winsup/cygwin/sched.cc | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/release/3.5.5 b/winsup/cygwin/release/3.5.5 index d91f2b92c..d41d168c6 100644 --- a/winsup/cygwin/release/3.5.5 +++ b/winsup/cygwin/release/3.5.5 @@ -45,3 +45,6 @@ Fixes: - Fix segfault in sigtimedwait() when using timeout. Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256762.html + +- sched_setscheduler(2) allows to change the priority if the policy is + equal to the value returned by sched_getscheduler(2). diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc index 39d0ed96b..a37e4f8b2 100644 --- a/winsup/cygwin/sched.cc +++ b/winsup/cygwin/sched.cc @@ -402,8 +402,11 @@ int sched_setscheduler (pid_t pid, int policy, const struct sched_param *param) { + if (policy == SCHED_FIFO) /* returned by sched_getscheduler. */ + return sched_setparam (pid, param); + /* on win32, you can't change the scheduler. Doh! */ - set_errno (ENOSYS); + set_errno (EINVAL); return -1; }