Commit | Line | Data |
---|---|---|
88b3ccf2 KB |
1 | .\" Copyright (c) 1980 The Regents of the University of California. |
2 | .\" All rights reserved. | |
e08c6f11 | 3 | .\" |
88b3ccf2 KB |
4 | .\" Redistribution and use in source and binary forms are permitted |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
16 | .\" @(#)getpriority.2 6.7 (Berkeley) %G% | |
e08c6f11 | 17 | .\" |
2b2683f7 | 18 | .TH GETPRIORITY 2 "" |
e08c6f11 KM |
19 | .UC 4 |
20 | .SH NAME | |
e0304aa6 | 21 | getpriority, setpriority \- get/set program scheduling priority |
e08c6f11 | 22 | .SH SYNOPSIS |
e0304aa6 KM |
23 | .nf |
24 | .ft B | |
bf57cfb2 | 25 | #include <sys/time.h> |
e0304aa6 KM |
26 | #include <sys/resource.h> |
27 | .PP | |
28 | .ft B | |
e0304aa6 KM |
29 | prio = getpriority(which, who) |
30 | int prio, which, who; | |
31 | .PP | |
32 | .ft B | |
33 | setpriority(which, who, prio) | |
34 | int which, who, prio; | |
35 | .fi | |
e08c6f11 KM |
36 | .SH DESCRIPTION |
37 | The scheduling | |
e0304aa6 KM |
38 | priority of the process, process group, or user, as indicated by |
39 | .I which | |
40 | and | |
41 | .I who | |
42 | is obtained with the | |
43 | .I getpriority | |
44 | call and set with the | |
45 | .I setpriority | |
46 | call. | |
47 | .I Which | |
48 | is one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER, and | |
49 | .I who | |
50 | is interpreted relative to | |
51 | .I which | |
52 | (a process identifier for PRIO_PROCESS, process group | |
53 | identifier for PRIO_PGRP, and a user ID for PRIO_USER). | |
f5c144bd JL |
54 | A zero value of |
55 | .I who | |
56 | denotes the current process, process group, or user. | |
e0304aa6 KM |
57 | .I Prio |
58 | is a value in the range \-20 to 20. The default priority is 0; | |
59 | lower priorities cause more favorable scheduling. | |
e08c6f11 | 60 | .PP |
e0304aa6 KM |
61 | The |
62 | .I getpriority | |
63 | call returns the highest priority (lowest numerical value) | |
64 | enjoyed by any of the specified processes. The | |
65 | .I setpriority | |
66 | call sets the priorities of all of the specified processes | |
67 | to the specified value. Only the super-user may lower priorities. | |
68 | .SH "RETURN VALUE | |
69 | Since | |
70 | .I getpriority | |
71 | can legitimately return the value \-1, it is necessary | |
72 | to clear the external variable \fIerrno\fP prior to the | |
73 | call, then check it afterward to determine | |
74 | if a \-1 is an error or a legitimate value. | |
75 | The | |
76 | .I setpriority | |
77 | call returns 0 if there is no error, or | |
78 | \-1 if there is. | |
79 | .SH ERRORS | |
80 | .I Getpriority | |
81 | and | |
82 | .I setpriority | |
83 | may return one of the following errors: | |
84 | .TP 15 | |
85 | [ESRCH] | |
9b8a2ecf | 86 | No process was located using the |
e0304aa6 KM |
87 | .I which |
88 | and | |
89 | .I who | |
90 | values specified. | |
91 | .TP 15 | |
92 | [EINVAL] | |
93 | .I Which | |
94 | was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. | |
e08c6f11 | 95 | .PP |
e0304aa6 KM |
96 | In addition to the errors indicated above, |
97 | .I setpriority | |
98 | may fail with one of the following errors returned: | |
99 | .TP 15 | |
327569e9 | 100 | [EPERM] |
e0304aa6 KM |
101 | A process was located, but neither its effective nor real user |
102 | ID matched the effective user ID of the caller. | |
103 | .TP 15 | |
104 | [EACCES] | |
9b8a2ecf | 105 | A non super-user attempted to lower a process priority. |
e08c6f11 KM |
106 | .SH "SEE ALSO" |
107 | nice(1), fork(2), renice(8) |