1GETPRIORITY(2) System Calls Manual GETPRIORITY(2)
2
3
4
6 getpriority, setpriority - get/set program scheduling priority
7
9 #include <sys/resource.h>
10
11 prio = getpriority(which, who)
12 int prio, which, who;
13
14 setpriority(which, who, prio)
15 int which, who, prio;
16
18 The scheduling priority of the process, process group, or user, as
19 indicated by which and who is obtained with the getpriority call and
20 set with the setpriority call. Which is one of PRIO_PROCESS,
21 PRIO_PGRP, or PRIO_USER, and who is interpreted relative to which (a
22 process identifier for PRIO_PROCESS, process group identifier for
23 PRIO_PGRP, and a user ID for PRIO_USER). A zero value of who denotes
24 the current process, process group, or user. Prio is a value in the
25 range -20 to 20. The default priority is 0; lower priorities cause
26 more favorable scheduling.
27
28 The getpriority call returns the highest priority (lowest numerical
29 value) enjoyed by any of the specified processes. The setpriority call
30 sets the priorities of all of the specified processes to the specified
31 value. Only the super-user may lower priorities.
32
34 Since getpriority can legitimately return the value -1, it is necessary
35 to clear the external variable errno prior to the call, then check it
36 afterward to determine if a -1 is an error or a legitimate value. The
37 setpriority call returns 0 if there is no error, or -1 if there is.
38
40 Getpriority and setpriority may return one of the following errors:
41
42 [ESRCH] No process was located using the which and who values
43 specified.
44
45 [EINVAL] Which was not one of PRIO_PROCESS, PRIO_PGRP, or
46 PRIO_USER.
47
48 In addition to the errors indicated above, setpriority may fail with
49 one of the following errors returned:
50
51 [EPERM] A process was located, but neither its effective nor
52 real user ID matched the effective user ID of the call‐
53 er.
54
55 [EACCES] A non super-user attempted to lower a process priority.
56
58 nice(1), fork(2), renice(8)
59
60
61
624th Berkeley Distribution May 22, 1986 GETPRIORITY(2)