diff options
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/nice.3 | 25 | ||||
-rw-r--r-- | lib/libc/gen/nice.c | 12 |
2 files changed, 32 insertions, 5 deletions
diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3 index 9c39b78..3bad5f7 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 22, 2015 .Dt NICE 3 .Os .Sh NAME @@ -57,11 +57,34 @@ 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 the new nice value minus +.Dv NZERO . +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 -xpg4.2 . .Sh HISTORY A .Fn nice diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c index e8375e8..58cde98 100644 --- a/lib/libc/gen/nice.c +++ b/lib/libc/gen/nice.c @@ -43,14 +43,18 @@ __FBSDID("$FreeBSD$"); * Backwards compatible nice. */ int -nice(incr) - int incr; +nice(int incr) { int prio; errno = 0; prio = getpriority(PRIO_PROCESS, 0); if (prio == -1 && errno) - return (-1); - return (setpriority(PRIO_PROCESS, 0, prio + incr)); + return -1; + if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { + if (errno == EACCES) + errno = EPERM; + return -1; + } + return getpriority(PRIO_PROCESS, 0); } |