1 .\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified by Michael Haardt <michael@moria.de>
6 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
7 .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
8 .\" Modified 2001-06-04 by aeb
9 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
11 .TH NICE 2 2021-03-22 "Linux" "Linux Programmer's Manual"
13 nice \- change process priority
16 .RI ( libc ", " \-lc )
19 .B #include <unistd.h>
21 .BI "int nice(int " inc );
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
32 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
33 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
39 to the nice value for the calling thread.
40 (A higher nice value means a lower priority.)
42 The range of the nice value is +19 (low priority) to \-20 (high priority).
43 Attempts to set a nice value outside the range are clamped to the range.
45 Traditionally, only a privileged process could lower the nice value
46 (i.e., set a higher priority).
47 However, since Linux 2.6.12, an unprivileged process can decrease
48 the nice value of a target process that has a suitable
54 On success, the new nice value is returned (but see NOTES below).
55 On error, \-1 is returned, and
57 is set to indicate the error.
59 A successful call can legitimately return \-1.
60 To detect an error, set
62 to 0 before the call, and check whether it is nonzero after
68 The calling process attempted to increase its priority by
71 but has insufficient privileges.
74 capability is required.
75 (But see the discussion of the
80 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
81 However, the raw system call and (g)libc
82 (earlier than glibc 2.2.4) return value is nonstandard, see below.
83 .\" SVr4 documents an additional
87 For further details on the nice value, see
91 the addition of the "autogroup" feature in Linux 2.6.38 means that
92 the nice value no longer has its traditional effect in many circumstances.
96 .SS C library/kernel differences
97 POSIX.1 specifies that
99 should return the new nice value.
100 However, the raw Linux system call returns 0 on success.
103 wrapper function provided in glibc 2.2.3 and earlier returns 0 on success.
105 Since glibc 2.2.4, the
107 wrapper function provided by glibc provides conformance to POSIX.1 by calling
109 to obtain the new nice value, which is then returned to the caller.
117 .BR capabilities (7),