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:
1 parent
74a28a8af2
commit
3aba2150d0
1 file changed
+8
-1
+8
-1
@@ -1,4 +1,5 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/resource.h>
|
||||
#include <limits.h>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user