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