From 3aba2150d0efc80df30d7fc6c22d6041e14d445e Mon Sep 17 00:00:00 2001 From: Alexey Kodanev Date: Tue, 29 Jun 2021 16:31:30 +0300 Subject: nice: return EPERM instead of EACCES To comply with POSIX, change errno from EACCES to EPERM when the caller did not have the required privilege. --- src/unistd/nice.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/unistd/nice.c b/src/unistd/nice.c index 6c25c8c3..1c2295ff 100644 --- a/src/unistd/nice.c +++ b/src/unistd/nice.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "syscall.h" @@ -12,5 +13,11 @@ int nice(int inc) prio += getpriority(PRIO_PROCESS, 0); if (prio > NZERO-1) prio = NZERO-1; if (prio < -NZERO) prio = -NZERO; - return setpriority(PRIO_PROCESS, 0, prio) ? -1 : prio; + if (setpriority(PRIO_PROCESS, 0, prio)) { + if (errno == EACCES) + errno = EPERM; + return -1; + } else { + return prio; + } } -- cgit 1.4.1