Gets or sets the nice value.
getpriority, setpriority: Standard C Library (libc.a)
nice: Standard C Library (libc.a)
Berkeley Compatibility Library (libbsd.a)
#include <sys/resource.h>
int getpriority( Which, Who)
int Which;
int Who;
int setpriority(Which, Who, Priority)
int Which;
int Who;
int Priority;
#include <unistd.h>
int nice( Increment)
int Increment;
The nice value of the process, process group, or user, as indicated by the Which and Who parameters is obtained with the getpriority subroutine and set with the setpriority subroutine.
The getpriority subroutine returns the highest priority nice value (lowest numerical value) pertaining to any of the specified processes. The setpriority subroutine sets the nice values of all of the specified processes to the specified value. If the specified value is less than -20, a value of -20 is used; if it is greater than 20, a value of 20 is used. Only processes that have root user authority can lower nice values.
The nice subroutine increments the nice value by the value of the Increment parameter.
To provide upward compatibility with older programs, the nice interface, originally found in AT&T System V, is supported.
If the behavior of the BSD version is desired, compile with the Berkeley Compatibility Library (libbsd.a). The Increment parameter is treated as the modifier of a value in the range -20 to 20.
On successful completion, the getpriority subroutine returns an integer in the range -20 to 20. A return value of -1 can also indicate an error, and in this case the errno global variable is set.
On successful completion, the setpriority subroutine returns 0. Otherwise, -1 is returned and the global variable errno is set to indicate the error.
On successful completion, the nice subroutine returns the new nice value minus {NZERO}. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The getpriority and setpriority subroutines are unsuccessful if one of the following is true:
ESRCH | No process was located using the Which and Who parameter values specified. |
EINVAL | The Which parameter was not recognized. |
In addition to the errors indicated above, the setpriority subroutine is unsuccessful if one of the following is true:
The nice subroutine is unsuccessful if the following is true:
EPERM | The Increment parameter is negative or greater than 2 * {NZERO} and the calling process does not have appropriate privileges. |
The exec (exec: execl, execle, execlp, execv, execve, execvp, or exect Subroutine) subroutines.
Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.