1NICE(2) Linux Programmer's Manual NICE(2)
2
3
4
6 nice - change process priority
7
9 #include <unistd.h>
10
11 int nice(int inc);
12
13 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15 nice():
16 _XOPEN_SOURCE
17 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
18 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
19
21 nice() adds inc to the nice value for the calling thread. (A higher
22 nice value means a lower priority.)
23
24 The range of the nice value is +19 (low priority) to -20 (high prior‐
25 ity). Attempts to set a nice value outside the range are clamped to
26 the range.
27
28 Traditionally, only a privileged process could lower the nice value
29 (i.e., set a higher priority). However, since Linux 2.6.12, an unpriv‐
30 ileged process can decrease the nice value of a target process that has
31 a suitable RLIMIT_NICE soft limit; see getrlimit(2) for details.
32
34 On success, the new nice value is returned (but see NOTES below). On
35 error, -1 is returned, and errno is set to indicate the error.
36
37 A successful call can legitimately return -1. To detect an error, set
38 errno to 0 before the call, and check whether it is nonzero after
39 nice() returns -1.
40
42 EPERM The calling process attempted to increase its priority by sup‐
43 plying a negative inc but has insufficient privileges. Under
44 Linux, the CAP_SYS_NICE capability is required. (But see the
45 discussion of the RLIMIT_NICE resource limit in setrlimit(2).)
46
48 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. However, the raw system call
49 and (g)libc (earlier than glibc 2.2.4) return value is nonstandard, see
50 below.
51
53 For further details on the nice value, see sched(7).
54
55 Note: the addition of the "autogroup" feature in Linux 2.6.38 means
56 that the nice value no longer has its traditional effect in many cir‐
57 cumstances. For details, see sched(7).
58
59 C library/kernel differences
60 POSIX.1 specifies that nice() should return the new nice value. How‐
61 ever, the raw Linux system call returns 0 on success. Likewise, the
62 nice() wrapper function provided in glibc 2.2.3 and earlier returns 0
63 on success.
64
65 Since glibc 2.2.4, the nice() wrapper function provided by glibc pro‐
66 vides conformance to POSIX.1 by calling getpriority(2) to obtain the
67 new nice value, which is then returned to the caller.
68
70 nice(1), renice(1), fork(2), getpriority(2), getrlimit(2), setprior‐
71 ity(2), capabilities(7), sched(7)
72
74 This page is part of release 5.13 of the Linux man-pages project. A
75 description of the project, information about reporting bugs, and the
76 latest version of this page, can be found at
77 https://www.kernel.org/doc/man-pages/.
78
79
80
81Linux 2021-03-22 NICE(2)