1nice(2)                       System Calls Manual                      nice(2)
2
3
4

NAME

6       nice - change process priority
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <unistd.h>
13
14       int nice(int inc);
15
16   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18       nice():
19           _XOPEN_SOURCE
20               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
21               || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
22

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

VERSIONS

51   C library/kernel differences
52       POSIX.1  specifies  that nice() should return the new nice value.  How‐
53       ever, the raw Linux system call returns 0 on  success.   Likewise,  the
54       nice()  wrapper  function provided in glibc 2.2.3 and earlier returns 0
55       on success.
56
57       Since glibc 2.2.4, the nice() wrapper function provided by  glibc  pro‐
58       vides  conformance  to  POSIX.1 by calling getpriority(2) to obtain the
59       new nice value, which is then returned to the caller.
60

STANDARDS

62       POSIX.1-2008.
63

HISTORY

65       POSIX.1-2001, SVr4, 4.3BSD.
66

NOTES

68       For further details on the nice value, see sched(7).
69
70       Note: the addition of the "autogroup" feature  in  Linux  2.6.38  means
71       that  the  nice value no longer has its traditional effect in many cir‐
72       cumstances.  For details, see sched(7).
73

SEE ALSO

75       nice(1), renice(1), fork(2),  getpriority(2),  getrlimit(2),  setprior‐
76       ity(2), capabilities(7), sched(7)
77
78
79
80Linux man-pages 6.05              2023-03-30                           nice(2)
Impressum