]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/nice.2
790aefd97f2e13ee9a3e27d0292adcbdb1c0ed31
[thirdparty/man-pages.git] / man2 / nice.2
1 .\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-06-04 by aeb
29 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
30 .\"
31 .TH NICE 2 2016-03-15 "Linux" "Linux Programmer's Manual"
32 .SH NAME
33 nice \- change process priority
34 .SH SYNOPSIS
35 .B #include <unistd.h>
36 .sp
37 .BI "int nice(int " inc );
38 .sp
39 .in -4n
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
42 .in
43 .sp
44 .BR nice ():
45 _XOPEN_SOURCE
46 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
47 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
48 .SH DESCRIPTION
49 .BR nice ()
50 adds
51 .I inc
52 to the nice value for the calling thread.
53 (A higher nice value means a low priority.)
54 Only the super\%user may specify a negative increment,
55 or priority increase.
56
57 The range of the nice value is +19 (low priority) to \-20 (high priority).
58 Attempts to set a nice value outside the range are clamped to the range.
59 .SH RETURN VALUE
60 On success, the new nice value is returned (but see NOTES below).
61 On error, \-1 is returned, and
62 .I errno
63 is set appropriately.
64 .SH ERRORS
65 .TP
66 .B EPERM
67 The calling process attempted to increase its priority by
68 supplying a negative
69 .I inc
70 but has insufficient privileges.
71 Under Linux, the
72 .B CAP_SYS_NICE
73 capability is required.
74 (But see the discussion of the
75 .B RLIMIT_NICE
76 resource limit in
77 .BR setrlimit (2).)
78 .SH CONFORMING TO
79 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
80 However, the Linux and (g)libc
81 (earlier than glibc 2.2.4) return value is nonstandard, see below.
82 SVr4 documents an additional
83 .B EINVAL
84 error code.
85 .SH NOTES
86 For further details on the nice value, see
87 .BR sched (7).
88
89 .IR Note :
90 the addition of the "autogroup" feature in Linux 2.6.38 means that
91 the nice value no longer has its traditional effect in many circumstances.
92 For details, see
93 .BR sched (7).
94
95 SUSv2 and POSIX.1 specify that
96 .BR nice ()
97 should return the new nice value.
98 However, the Linux system call and the
99 .BR nice ()
100 library function provided in older versions of (g)libc
101 (earlier than glibc 2.2.4) return 0 on success.
102 The new nice value can be found using
103 .BR getpriority (2).
104 .\"
105 .SS C library/kernel differences
106 Since glibc 2.2.4,
107 .BR nice ()
108 is implemented as a library function that calls
109 .BR getpriority (2)
110 to obtain the new nice value to be returned to the caller.
111 With this implementation,
112 a successful call can legitimately return \-1.
113 To reliably detect an error, set
114 .I errno
115 to 0 before the call, and check its value when
116 .BR nice ()
117 returns \-1.
118 .SH SEE ALSO
119 .BR nice (1),
120 .BR renice (1),
121 .BR fork (2),
122 .BR getpriority (2),
123 .BR setpriority (2),
124 .BR capabilities (7),
125 .BR sched (7)