From 32ff4802941c2828d99985f6808c6c8e3d7d74fa Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 5 Dec 2016 09:13:52 +0100 Subject: [PATCH] nice.2: Rework discussion of nice() return value and standards conformance Make the text a little clearer. In particular, clarify that the raw system call (still) returns 0 on success. Signed-off-by: Michael Kerrisk --- man2/nice.2 | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/man2/nice.2 b/man2/nice.2 index 93ae89b6d..3b741d470 100644 --- a/man2/nice.2 +++ b/man2/nice.2 @@ -84,7 +84,7 @@ resource limit in .BR setrlimit (2).) .SH CONFORMING TO POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. -However, the Linux and (g)libc +However, the raw system call and (g)libc (earlier than glibc 2.2.4) return value is nonstandard, see below. SVr4 documents an additional .B EINVAL @@ -98,23 +98,21 @@ the addition of the "autogroup" feature in Linux 2.6.38 means that the nice value no longer has its traditional effect in many circumstances. For details, see .BR sched (7). - -SUSv2 and POSIX.1 specify that -.BR nice () -should return the new nice value. -However, the Linux system call and the -.BR nice () -library function provided in older versions of (g)libc -(earlier than glibc 2.2.4) return 0 on success. -The new nice value can be found using -.BR getpriority (2). .\" .SS C library/kernel differences -Since glibc 2.2.4, +POSIX.1 specifies that .BR nice () -is implemented as a library function that calls +should return the new nice value. +However, the raw Linux system call returns 0 on success. +Likewise, the +.BR nice () +wrapper function provided in glibc 2.2.3 and earlier returns 0 on success. + +Since glibc 2.2.4, the +.BR nice () +wrapper function provided by glibc provides conformance to POSIX.1 by calling .BR getpriority (2) -to obtain the new nice value to be returned to the caller. +to obtain the new nice value, which is then returned to the caller. With this implementation, a successful call can legitimately return \-1. To reliably detect an error, set