written by Kirk McKusick and Sam Leffler; add Berkeley specific header
[unix-history] / usr / src / lib / libc / sys / getpriority.2
CommitLineData
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 10getpriority, 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
17prio = getpriority(which, who)
18int prio, which, who;
19.PP
20.ft B
21setpriority(which, who, prio)
22int which, who, prio;
23.fi
e08c6f11
KM
24.SH DESCRIPTION
25The scheduling
e0304aa6
KM
26priority of the process, process group, or user, as indicated by
27.I which
28and
29.I who
30is obtained with the
31.I getpriority
32call and set with the
33.I setpriority
34call.
35.I Which
36is one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER, and
37.I who
38is interpreted relative to
39.I which
40(a process identifier for PRIO_PROCESS, process group
41identifier for PRIO_PGRP, and a user ID for PRIO_USER).
f5c144bd
JL
42A zero value of
43.I who
44denotes the current process, process group, or user.
e0304aa6
KM
45.I Prio
46is a value in the range \-20 to 20. The default priority is 0;
47lower priorities cause more favorable scheduling.
e08c6f11 48.PP
e0304aa6
KM
49The
50.I getpriority
51call returns the highest priority (lowest numerical value)
52enjoyed by any of the specified processes. The
53.I setpriority
54call sets the priorities of all of the specified processes
55to the specified value. Only the super-user may lower priorities.
56.SH "RETURN VALUE
57Since
58.I getpriority
59can legitimately return the value \-1, it is necessary
60to clear the external variable \fIerrno\fP prior to the
61call, then check it afterward to determine
62if a \-1 is an error or a legitimate value.
63The
64.I setpriority
65call returns 0 if there is no error, or
66\-1 if there is.
67.SH ERRORS
68.I Getpriority
69and
70.I setpriority
71may return one of the following errors:
72.TP 15
73[ESRCH]
9b8a2ecf 74No process was located using the
e0304aa6
KM
75.I which
76and
77.I who
78values specified.
79.TP 15
80[EINVAL]
81.I Which
82was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
e08c6f11 83.PP
e0304aa6
KM
84In addition to the errors indicated above,
85.I setpriority
86may fail with one of the following errors returned:
87.TP 15
327569e9 88[EPERM]
e0304aa6
KM
89A process was located, but neither its effective nor real user
90ID matched the effective user ID of the caller.
91.TP 15
92[EACCES]
9b8a2ecf 93A non super-user attempted to lower a process priority.
e08c6f11
KM
94.SH "SEE ALSO"
95nice(1), fork(2), renice(8)