From d881b8eb8843bab6213c03d985c02dbbff945c39 Mon Sep 17 00:00:00 2001
From: ngie <ngie@FreeBSD.org>
Date: Thu, 9 Feb 2017 21:19:24 +0000
Subject: MFC r279154,r279397:

r279154 (by jilles):

nice(): Correct return value and [EPERM] error.

PR:		189821
Obtained from:	NetBSD
Relnotes:	yes

r279397 (by jilles):

nice(): Put back old return value, keeping [EPERM] error.

Commit r279154 changed the API and ABI significantly, and {NZERO} is still
wrong.

Also, preserve errno on success instead of setting it to 0.

PR:		189821
Relnotes:	yes
---
 lib/libc/gen/nice.3 | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

(limited to 'lib/libc/gen/nice.3')

diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3
index 9c39b78..8ce13af 100644
--- a/lib/libc/gen/nice.3
+++ b/lib/libc/gen/nice.3
@@ -28,7 +28,7 @@
 .\"     @(#)nice.3	8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd February 28, 2015
 .Dt NICE 3
 .Os
 .Sh NAME
@@ -48,20 +48,48 @@ This interface is obsoleted by
 .Pp
 The
 .Fn nice
-function obtains the scheduling priority of the process
-from the system and sets it to the priority value specified in
-.Fa incr .
+function adds
+.Fa incr
+to the scheduling priority of the process.
 The priority is a value in the range -20 to 20.
 The default priority is 0; lower priorities cause more favorable scheduling.
 Only the super-user may lower priorities.
 .Pp
 Children inherit the priority of their parent processes via
 .Xr fork 2 .
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn nice
+returns 0, and
+.Va errno
+is unchanged.
+Otherwise, \-1 is returned, the process' nice value is not changed, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn nice
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The
+.Fa incr
+argument is negative and the caller does not have appropriate privileges.
+.El
 .Sh SEE ALSO
 .Xr nice 1 ,
 .Xr fork 2 ,
 .Xr setpriority 2 ,
 .Xr renice 8
+.Sh STANDARDS
+The
+.Fn nice
+function conforms to
+.St -p1003.1-2008
+except for the return value.
+This implementation returns 0 upon successful completion but 
+the standard requires returning the new nice value,
+which could be \-1.
 .Sh HISTORY
 A
 .Fn nice
-- 
cgit v1.1