Commit | Line | Data |
---|---|---|
e08c6f11 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
393df2ab | 5 | .\" @(#)getpriority.2 6.5 (Berkeley) %G% |
e08c6f11 | 6 | .\" |
2b2683f7 | 7 | .TH GETPRIORITY 2 "" |
e08c6f11 KM |
8 | .UC 4 |
9 | .SH NAME | |
e0304aa6 | 10 | getpriority, setpriority \- get/set program scheduling priority |
e08c6f11 | 11 | .SH SYNOPSIS |
e0304aa6 KM |
12 | .nf |
13 | .ft B | |
14 | #include <sys/resource.h> | |
15 | .PP | |
16 | .ft B | |
e0304aa6 KM |
17 | prio = getpriority(which, who) |
18 | int prio, which, who; | |
19 | .PP | |
20 | .ft B | |
21 | setpriority(which, who, prio) | |
22 | int which, who, prio; | |
23 | .fi | |
e08c6f11 KM |
24 | .SH DESCRIPTION |
25 | The scheduling | |
e0304aa6 KM |
26 | priority of the process, process group, or user, as indicated by |
27 | .I which | |
28 | and | |
29 | .I who | |
30 | is obtained with the | |
31 | .I getpriority | |
32 | call and set with the | |
33 | .I setpriority | |
34 | call. | |
35 | .I Which | |
36 | is one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER, and | |
37 | .I who | |
38 | is interpreted relative to | |
39 | .I which | |
40 | (a process identifier for PRIO_PROCESS, process group | |
41 | identifier for PRIO_PGRP, and a user ID for PRIO_USER). | |
f5c144bd JL |
42 | A zero value of |
43 | .I who | |
44 | denotes the current process, process group, or user. | |
e0304aa6 KM |
45 | .I Prio |
46 | is a value in the range \-20 to 20. The default priority is 0; | |
47 | lower priorities cause more favorable scheduling. | |
e08c6f11 | 48 | .PP |
e0304aa6 KM |
49 | The |
50 | .I getpriority | |
51 | call returns the highest priority (lowest numerical value) | |
52 | enjoyed by any of the specified processes. The | |
53 | .I setpriority | |
54 | call sets the priorities of all of the specified processes | |
55 | to the specified value. Only the super-user may lower priorities. | |
56 | .SH "RETURN VALUE | |
57 | Since | |
58 | .I getpriority | |
59 | can legitimately return the value \-1, it is necessary | |
60 | to clear the external variable \fIerrno\fP prior to the | |
61 | call, then check it afterward to determine | |
62 | if a \-1 is an error or a legitimate value. | |
63 | The | |
64 | .I setpriority | |
65 | call returns 0 if there is no error, or | |
66 | \-1 if there is. | |
67 | .SH ERRORS | |
68 | .I Getpriority | |
69 | and | |
70 | .I setpriority | |
71 | may return one of the following errors: | |
72 | .TP 15 | |
73 | [ESRCH] | |
9b8a2ecf | 74 | No process was located using the |
e0304aa6 KM |
75 | .I which |
76 | and | |
77 | .I who | |
78 | values specified. | |
79 | .TP 15 | |
80 | [EINVAL] | |
81 | .I Which | |
82 | was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. | |
e08c6f11 | 83 | .PP |
e0304aa6 KM |
84 | In addition to the errors indicated above, |
85 | .I setpriority | |
86 | may fail with one of the following errors returned: | |
87 | .TP 15 | |
327569e9 | 88 | [EPERM] |
e0304aa6 KM |
89 | A process was located, but neither its effective nor real user |
90 | ID matched the effective user ID of the caller. | |
91 | .TP 15 | |
92 | [EACCES] | |
9b8a2ecf | 93 | A non super-user attempted to lower a process priority. |
e08c6f11 KM |
94 | .SH "SEE ALSO" |
95 | nice(1), fork(2), renice(8) |