Commit | Line | Data |
---|---|---|
931b8415 | 1 | .\" Copyright (c) 1980, 1991 The Regents of the University of California. |
88b3ccf2 | 2 | .\" All rights reserved. |
e08c6f11 | 3 | .\" |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
88b3ccf2 | 5 | .\" |
931b8415 | 6 | .\" @(#)getpriority.2 6.9 (Berkeley) %G% |
e08c6f11 | 7 | .\" |
931b8415 CL |
8 | .Dd |
9 | .Dt GETPRIORITY 2 | |
10 | .Os BSD 4 | |
11 | .Sh NAME | |
12 | .Nm getpriority , | |
13 | .Nm setpriority | |
14 | .Nd get/set program scheduling priority | |
15 | .Sh SYNOPSIS | |
16 | .Fd #include <sys/time.h> | |
17 | .Fd #include <sys/resource.h> | |
18 | .Ft int | |
19 | .Fn getpriority "int which" "int who" | |
20 | .Ft int | |
21 | .Fn setpriority "int which" "int who" "int prio" | |
22 | .Sh DESCRIPTION | |
e08c6f11 | 23 | The scheduling |
e0304aa6 | 24 | priority of the process, process group, or user, as indicated by |
931b8415 | 25 | .Fa which |
e0304aa6 | 26 | and |
931b8415 | 27 | .Fa who |
e0304aa6 | 28 | is obtained with the |
931b8415 | 29 | .Fn getpriority |
e0304aa6 | 30 | call and set with the |
931b8415 | 31 | .Fn setpriority |
e0304aa6 | 32 | call. |
931b8415 CL |
33 | .Fa Which |
34 | is one of | |
35 | .Dv PRIO_PROCESS , | |
36 | .Dv PRIO_PGRP , | |
37 | or | |
38 | .Dv PRIO_USER , | |
39 | and | |
40 | .Fa who | |
e0304aa6 | 41 | is interpreted relative to |
931b8415 CL |
42 | .Fa which |
43 | (a process identifier for | |
44 | .Dv PRIO_PROCESS , | |
45 | process group | |
46 | identifier for | |
47 | .Dv PRIO_PGRP , | |
48 | and a user ID for | |
49 | .Dv PRIO_USER ) . | |
f5c144bd | 50 | A zero value of |
931b8415 | 51 | .Fa who |
f5c144bd | 52 | denotes the current process, process group, or user. |
931b8415 CL |
53 | .Fa Prio |
54 | is a value in the range -20 to 20. The default priority is 0; | |
e0304aa6 | 55 | lower priorities cause more favorable scheduling. |
931b8415 | 56 | .Pp |
e0304aa6 | 57 | The |
931b8415 | 58 | .Fn getpriority |
e0304aa6 KM |
59 | call returns the highest priority (lowest numerical value) |
60 | enjoyed by any of the specified processes. The | |
931b8415 | 61 | .Fn setpriority |
e0304aa6 KM |
62 | call sets the priorities of all of the specified processes |
63 | to the specified value. Only the super-user may lower priorities. | |
931b8415 | 64 | .Sh RETURN VALUES |
e0304aa6 | 65 | Since |
931b8415 CL |
66 | .Fn getpriority |
67 | can legitimately return the value -1, it is necessary | |
68 | to clear the external variable | |
69 | .Va errno | |
70 | prior to the | |
e0304aa6 | 71 | call, then check it afterward to determine |
931b8415 | 72 | if a -1 is an error or a legitimate value. |
e0304aa6 | 73 | The |
931b8415 | 74 | .Fn setpriority |
e0304aa6 | 75 | call returns 0 if there is no error, or |
931b8415 CL |
76 | -1 if there is. |
77 | .Sh ERRORS | |
78 | .Fn Getpriority | |
e0304aa6 | 79 | and |
931b8415 CL |
80 | .Fn setpriority |
81 | will fail if: | |
82 | .Bl -tag -width Er | |
83 | .It Bq Er ESRCH | |
9b8a2ecf | 84 | No process was located using the |
931b8415 | 85 | .Fa which |
e0304aa6 | 86 | and |
931b8415 | 87 | .Fa who |
e0304aa6 | 88 | values specified. |
931b8415 CL |
89 | .It Bq Er EINVAL |
90 | .Fa Which | |
91 | was not one of | |
92 | .Dv PRIO_PROCESS , | |
93 | .Dv PRIO_PGRP , | |
94 | or | |
95 | .Dv PRIO_USER . | |
96 | .El | |
97 | .Pp | |
98 | .Bl -tag -width Er | |
e0304aa6 | 99 | In addition to the errors indicated above, |
931b8415 CL |
100 | .Fn setpriority |
101 | will fail if: | |
102 | .It Bq Er EPERM | |
e0304aa6 KM |
103 | A process was located, but neither its effective nor real user |
104 | ID matched the effective user ID of the caller. | |
931b8415 | 105 | .It Bq Er EACCES |
9b8a2ecf | 106 | A non super-user attempted to lower a process priority. |
931b8415 CL |
107 | .El |
108 | .Sh SEE ALSO | |
109 | .Xr nice 1 , | |
110 | .Xr fork 2 , | |
111 | .Xr renice 8 | |
112 | .Sh HISTORY | |
113 | The | |
114 | .Nm | |
115 | function call appeared in | |
116 | .Bx 4.2 . |