1NICE(2)                    Linux Programmer's Manual                   NICE(2)
2
3
4

NAME

6       nice - change process priority
7

SYNOPSIS

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(): _XOPEN_SOURCE
16           || /* Since glibc 2.19: */ _DEFAULT_SOURCE
17           || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
18

DESCRIPTION

20       nice()  adds  inc  to the nice value for the calling thread.  (A higher
21       nice value means a low priority.)
22
23       The range of the nice value is +19 (low priority) to -20  (high  prior‐
24       ity).   Attempts  to  set a nice value outside the range are clamped to
25       the range.
26
27       Traditionally, only a privileged process could  lower  the  nice  value
28       (i.e., set a higher priority).  However, since Linux 2.6.12, an unpriv‐
29       ileged process can decrease the nice value of a target process that has
30       a suitable RLIMIT_NICE soft limit; see getrlimit(2) for details.
31

RETURN VALUE

33       On  success,  the new nice value is returned (but see NOTES below).  On
34       error, -1 is returned, and errno is set appropriately.
35
36       A successful call can legitimately return -1.  To detect an error,  set
37       errno  to  0  before  the  call,  and check whether it is nonzero after
38       nice() returns -1.
39

ERRORS

41       EPERM  The calling process attempted to increase its priority  by  sup‐
42              plying  a  negative  inc but has insufficient privileges.  Under
43              Linux, the CAP_SYS_NICE capability is required.   (But  see  the
44              discussion of the RLIMIT_NICE resource limit in setrlimit(2).)
45

CONFORMING TO

47       POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.  However, the raw system call
48       and (g)libc (earlier than glibc 2.2.4) return value is nonstandard, see
49       below.
50

NOTES

52       For further details on the nice value, see sched(7).
53
54       Note:  the  addition  of  the "autogroup" feature in Linux 2.6.38 means
55       that the nice value no longer has its traditional effect in  many  cir‐
56       cumstances.  For details, see sched(7).
57
58   C library/kernel differences
59       POSIX.1  specifies  that nice() should return the new nice value.  How‐
60       ever, the raw Linux system call returns 0 on  success.   Likewise,  the
61       nice()  wrapper  function provided in glibc 2.2.3 and earlier returns 0
62       on success.
63
64       Since glibc 2.2.4, the nice() wrapper function provided by  glibc  pro‐
65       vides  conformance  to  POSIX.1 by calling getpriority(2) to obtain the
66       new nice value, which is then returned to the caller.
67

SEE ALSO

69       nice(1), renice(1), fork(2),  getpriority(2),  getrlimit(2),  setprior‐
70       ity(2), capabilities(7), sched(7)
71

COLOPHON

73       This  page  is  part of release 4.15 of the Linux man-pages project.  A
74       description of the project, information about reporting bugs,  and  the
75       latest     version     of     this    page,    can    be    found    at
76       https://www.kernel.org/doc/man-pages/.
77
78
79
80Linux                             2017-09-15                           NICE(2)
Impressum