1NICE(3P) POSIX Programmer's Manual NICE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 nice — change the nice value of a process
14
16 #include <unistd.h>
17
18 int nice(int incr);
19
21 The nice() function shall add the value of incr to the nice value of
22 the calling process. A nice value of a process is a non-negative number
23 for which a more positive value shall result in less favorable schedul‐
24 ing.
25
26 A maximum nice value of 2*{NZERO}−1 and a minimum nice value of 0 shall
27 be imposed by the system. Requests for values above or below these lim‐
28 its shall result in the nice value being set to the corresponding
29 limit. Only a process with appropriate privileges can lower the nice
30 value.
31
32 Calling the nice() function has no effect on the priority of processes
33 or threads with policy SCHED_FIFO or SCHED_RR. The effect on processes
34 or threads with other scheduling policies is implementation-defined.
35
36 The nice value set with nice() shall be applied to the process. If the
37 process is multi-threaded, the nice value shall affect all system scope
38 threads in the process.
39
40 As −1 is a permissible return value in a successful situation, an
41 application wishing to check for error situations should set errno to
42 0, then call nice(), and if it returns −1, check to see whether errno
43 is non-zero.
44
46 Upon successful completion, nice() shall return the new nice value
47 −{NZERO}. Otherwise, −1 shall be returned, the nice value of the
48 process shall not be changed, and errno shall be set to indicate the
49 error.
50
52 The nice() function shall fail if:
53
54 EPERM The incr argument is negative and the calling process does not
55 have appropriate privileges.
56
57 The following sections are informative.
58
60 Changing the Nice Value
61 The following example adds the value of the incr argument, −20, to the
62 nice value of the calling process.
63
64 #include <unistd.h>
65 ...
66 int incr = -20;
67 int ret;
68
69 ret = nice(incr);
70
72 None.
73
75 None.
76
78 None.
79
81 exec, getpriority()
82
83 The Base Definitions volume of POSIX.1‐2008, <limits.h>, <unistd.h>
84
86 Portions of this text are reprinted and reproduced in electronic form
87 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
88 -- Portable Operating System Interface (POSIX), The Open Group Base
89 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
90 cal and Electronics Engineers, Inc and The Open Group. (This is
91 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
92 event of any discrepancy between this version and the original IEEE and
93 The Open Group Standard, the original IEEE and The Open Group Standard
94 is the referee document. The original Standard can be obtained online
95 at http://www.unix.org/online.html .
96
97 Any typographical or formatting errors that appear in this page are
98 most likely to have been introduced during the conversion of the source
99 files to man page format. To report such errors, see https://www.ker‐
100 nel.org/doc/man-pages/reporting_bugs.html .
101
102
103
104IEEE/The Open Group 2013 NICE(3P)