Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/resource.h>
int getpriority(int which, id_t who);
getpriority() obtains the current priority of a process, process group or user.
The who argument specifies the ID (process, process group, or user). A 0 (zero) value for the who argument specifies the current process, process group or user ID.
If successful, getpriority() returns the priority of the process, process group, or used ID requested in who. The priority is returned as an integer in the range -20 to 19 (the lower the numerical value, the higher the priority).
If more than one process is specified, getpriority() returns the highest priority pertaining to any of the specified processes.
Because getpriority() can return the value -1 on successful completion, it is necessary to set the external variable errno to 0 before a call to getpriority(). If getpriority() returns -1, then errno can be checked to see if an error occurred or if the value is a legitimate priority.