]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/getpriority.2
zfs: merge openzfs/zfs@a03ebd9be
[FreeBSD/FreeBSD.git] / lib / libc / sys / getpriority.2
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .Dd June 4, 1993
29 .Dt GETPRIORITY 2
30 .Os
31 .Sh NAME
32 .Nm getpriority ,
33 .Nm setpriority
34 .Nd get/set program scheduling priority
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In sys/time.h
39 .In sys/resource.h
40 .Ft int
41 .Fn getpriority "int which" "int who"
42 .Ft int
43 .Fn setpriority "int which" "int who" "int prio"
44 .Sh DESCRIPTION
45 The scheduling
46 priority of the process, process group, or user, as indicated by
47 .Fa which
48 and
49 .Fa who
50 is obtained with the
51 .Fn getpriority
52 system call and set with the
53 .Fn setpriority
54 system call.
55 The
56 .Fa which
57 argument
58 is one of
59 .Dv PRIO_PROCESS ,
60 .Dv PRIO_PGRP ,
61 or
62 .Dv PRIO_USER ,
63 and
64 .Fa who
65 is interpreted relative to
66 .Fa which
67 (a process identifier for
68 .Dv PRIO_PROCESS ,
69 process group
70 identifier for
71 .Dv PRIO_PGRP ,
72 and a user ID for
73 .Dv PRIO_USER ) .
74 A zero value of
75 .Fa who
76 denotes the current process, process group, or user.
77 The
78 .Fa prio
79 argument
80 is a value in the range -20 to 20.
81 The default priority is 0;
82 lower priorities cause more favorable scheduling.
83 .Pp
84 The
85 .Fn getpriority
86 system call returns the highest priority (lowest numerical value)
87 enjoyed by any of the specified processes.
88 The
89 .Fn setpriority
90 system call sets the priorities of all of the specified processes
91 to the specified value.
92 Only the super-user may lower priorities.
93 .Sh RETURN VALUES
94 Since
95 .Fn getpriority
96 can legitimately return the value -1, it is necessary
97 to clear the external variable
98 .Va errno
99 prior to the
100 call, then check it afterward to determine
101 if a -1 is an error or a legitimate value.
102 .Pp
103 .Rv -std setpriority
104 .Sh ERRORS
105 The
106 .Fn getpriority
107 and
108 .Fn setpriority
109 system calls
110 will fail if:
111 .Bl -tag -width Er
112 .It Bq Er ESRCH
113 No process was located using the
114 .Fa which
115 and
116 .Fa who
117 values specified.
118 .It Bq Er EINVAL
119 The
120 .Fa which
121 argument
122 was not one of
123 .Dv PRIO_PROCESS ,
124 .Dv PRIO_PGRP ,
125 or
126 .Dv PRIO_USER .
127 .El
128 .Pp
129 In addition to the errors indicated above,
130 .Fn setpriority
131 will fail if:
132 .Bl -tag -width Er
133 .It Bq Er EPERM
134 A process was located, but neither its effective nor real user
135 ID matched the effective user ID of the caller.
136 .It Bq Er EACCES
137 A non super-user attempted to lower a process priority.
138 .El
139 .Sh SEE ALSO
140 .Xr nice 1 ,
141 .Xr fork 2 ,
142 .Xr renice 8
143 .Sh HISTORY
144 The
145 .Fn getpriority
146 system call appeared in
147 .Bx 4.2 .