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(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
16
18 nice() adds inc to the nice value for the calling process. (A higher
19 nice value means a low priority.) Only the superuser may specify a
20 negative increment, or priority increase. The range for nice values is
21 described in getpriority(2).
22
24 On success, the new nice value is returned (but see NOTES below). On
25 error, -1 is returned, and errno is set appropriately.
26
28 EPERM The calling process attempted to increase its priority by sup‐
29 plying a negative inc but has insufficient privileges. Under
30 Linux the CAP_SYS_NICE capability is required. (But see the
31 discussion of the RLIMIT_NICE resource limit in setrlimit(2).)
32
34 SVr4, 4.3BSD, POSIX.1-2001. However, the Linux and (g)libc (earlier
35 than glibc 2.2.4) return value is nonstandard, see below. SVr4 docu‐
36 ments an additional EINVAL error code.
37
39 SUSv2 and POSIX.1-2001 specify that nice() should return the new nice
40 value. However, the Linux syscall and the nice() library function pro‐
41 vided in older versions of (g)libc (earlier than glibc 2.2.4) return 0
42 on success. The new nice value can be found using getpriority(2).
43
44 Since glibc 2.2.4, nice() is implemented as a library function that
45 calls getpriority(2) to obtain the new nice value to be returned to the
46 caller. With this implementation, a successful call can legitimately
47 return -1. To reliably detect an error, set errno to 0 before the
48 call, and check its value when nice() returns -1.
49
51 nice(1), renice(1), fork(2), getpriority(2), setpriority(2), capabili‐
52 ties(7)
53
55 This page is part of release 3.53 of the Linux man-pages project. A
56 description of the project, and information about reporting bugs, can
57 be found at http://www.kernel.org/doc/man-pages/.
58
59
60
61Linux 2007-07-26 NICE(2)