mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
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.
This commit is contained in:
parent
74a28a8af2
commit
3aba2150d0
1 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
|
@ -12,5 +13,11 @@ int nice(int inc)
|
||||||
prio += getpriority(PRIO_PROCESS, 0);
|
prio += getpriority(PRIO_PROCESS, 0);
|
||||||
if (prio > NZERO-1) prio = NZERO-1;
|
if (prio > NZERO-1) prio = NZERO-1;
|
||||||
if (prio < -NZERO) prio = -NZERO;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue