diff --git a/man2/nice.2 b/man2/nice.2 index 0873c3c3a..2142d07ff 100644 --- a/man2/nice.2 +++ b/man2/nice.2 @@ -28,7 +28,7 @@ .\" Modified 2001-06-04 by aeb .\" Modified 2004-05-27 by Michael Kerrisk .\" -.TH NICE 2 2004-05-27 "Linux 2.6.6" "Linux Programmer's Manual" +.TH NICE 2 2005-06-16 "Linux 2.6.12" "Linux Programmer's Manual" .SH NAME nice \- change process priority .SH SYNOPSIS @@ -36,14 +36,15 @@ nice \- change process priority .sp .BI "int nice(int " inc ); .SH DESCRIPTION -.B nice +.BR nice () adds .I inc to the nice value for the calling pid. (A large nice value means a low priority.) Only the super\%user may specify a negative increment, or priority increase. .SH "RETURN VALUE" -On success, zero is returned. On error, \-1 is returned, and +On success, the new nice value is returned (but see NOTES below). +On error, \-1 is returned, and .I errno is set appropriately. .SH ERRORS @@ -59,21 +60,32 @@ capability is required. .SH "CONFORMING TO" SVr4, SVID EXT, AT&T, X/OPEN, BSD 4.3. However, the Linux and glibc (earlier than glibc 2.2.4) return value is nonstandard, see below. -SVr4 documents an additional -EINVAL error code. +SVr4 documents an additional EINVAL error code. .SH NOTES -Note that the routine is documented in SUSv2 and POSIX 1003.1-2003 -to return the new nice value, while the Linux syscall and (g)libc -(earlier than glibc 2.2.4) routines return 0 on success. -The new nice value can be found using +SUSv2 and POSIX 1003.1-2003 specify that +.BR nice () +should return the new nice value. +However, the Linux syscall and the +.BR nice () +library function provided in older versions of glibc +(earlier than glibc 2.2.4) return 0 on success. +In this case, the new nice value can be found using .BR getpriority (2). -Note that an implementation in which -.B nice -returns the new nice value can legitimately return \-1. + +Since glibc 2.2.4, +.BR nice () +is implemented as a library function that calls +.BR getpriority (2) +to obtain the new nice value, +and this is returned to the caller as the function result of the +.BR nice () +call. +With this implementation, +a successful call can can legitimately return \-1. To reliably detect an error, set .I errno to 0 before the call, and check its value when -.B nice +.BR nice () returns \-1. .SH "SEE ALSO" .BR nice (1),