From d818502d25778df1e5ebbceddb05e6fd55e53a23 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 28 Jul 2005 13:21:39 +0000 Subject: [PATCH] Expanded discussion of relationship between user and kernel representations of the nice value. Added mention of RLIMIT_NICE and a cross reference to getrlimit.2 under the description of the EACCES error. --- man2/getpriority.2 | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/man2/getpriority.2 b/man2/getpriority.2 index 9453bb223..1ed1e1967 100644 --- a/man2/getpriority.2 +++ b/man2/getpriority.2 @@ -134,12 +134,21 @@ may fail if: .B EPERM A process was located, but its effective user ID did not match either the effective or the real user ID of the caller, -and (on Linux systems) the caller did not have the +and was not privileged (on Linux: did not have the .B CAP_SYS_NICE -capability. +capability). .TP .B EACCES -A non superuser attempted to lower a process priority. +The caller attempted to lower a process priority, but did not +have the required privilege (on Linux: did not have the +.B CAP_SYS_NICE +capability). +Since Linux 2.6.12, this error only occurs if the caller attempts +to set a process priority outside the range of its +.B RLIMIT_NICE +resource limit; see +.BR getrlimit (2) +for details. .SH NOTES The details on the condition for EPERM depend on the system. The above description is what SUSv3 says, and seems to be followed on @@ -152,10 +161,20 @@ the effective user ID of the caller to match the real or effective user ID of the process \fIwho\fP. .LP The actual priority range varies between kernel versions. -Linux before 1.3.36 had \-infinity..15. Linux since 1.3.43 has \-20..19, -and the system call getpriority returns 40..1 for these values -(since negative numbers are error codes). -The library call converts N into 20\-N. +Linux before 1.3.36 had \-infinity..15. +Since kerenl 1.3.43 Linux has the range \-20..19. +Within the kernel, nice values are actually represented +using the corresponding range 40..1 +(since negative numbers are error codes) and these are the values +employed by the +.B setpriority +and +.B getpriority +system calls. +The glibc wrapper functions for these system calls handle the +translations between the user-land and kernel representations +of the nice value according to the formula +.IR "unice\ =\ 20\ \-\ knice" . .LP On some systems, the range of nice values is \-20..20. .LP