]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992 |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" Modified by Michael Haardt <michael@moria.de> | |
26 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
27 | .\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com> | |
28 | .\" Modified 2001-06-04 by aeb | |
c11b1abf | 29 | .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 30 | .\" |
4b8c67d9 | 31 | .TH NICE 2 2017-09-15 "Linux" "Linux Programmer's Manual" |
fea681da MK |
32 | .SH NAME |
33 | nice \- change process priority | |
34 | .SH SYNOPSIS | |
35 | .B #include <unistd.h> | |
68e4db0a | 36 | .PP |
fea681da | 37 | .BI "int nice(int " inc ); |
68e4db0a | 38 | .PP |
cc4615cc MK |
39 | .in -4n |
40 | Feature Test Macro Requirements for glibc (see | |
41 | .BR feature_test_macros (7)): | |
42 | .in | |
68e4db0a | 43 | .PP |
4e3b3468 | 44 | .BR nice (): |
f8619b6a MK |
45 | _XOPEN_SOURCE |
46 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
2c767761 | 47 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
fea681da | 48 | .SH DESCRIPTION |
2a019416 | 49 | .BR nice () |
c13182ef | 50 | adds |
fea681da | 51 | .I inc |
57865ad7 | 52 | to the nice value for the calling thread. |
70cbdedf | 53 | (A higher nice value means a low priority.) |
efeece04 | 54 | .PP |
4d9db1bd MK |
55 | The range of the nice value is +19 (low priority) to \-20 (high priority). |
56 | Attempts to set a nice value outside the range are clamped to the range. | |
efeece04 | 57 | .PP |
52694f09 MK |
58 | Traditionally, only a privileged process could lower the nice value |
59 | (i.e., set a higher priority). | |
60 | However, since Linux 2.6.12, an unprivileged process can decrease | |
61 | the nice value of a target process that has a suitable | |
62 | .BR RLIMIT_NICE | |
63 | soft limit; see | |
64 | .BR getrlimit (2) | |
65 | for details. | |
47297adb | 66 | .SH RETURN VALUE |
2a019416 MK |
67 | On success, the new nice value is returned (but see NOTES below). |
68 | On error, \-1 is returned, and | |
fea681da MK |
69 | .I errno |
70 | is set appropriately. | |
efeece04 | 71 | .PP |
540038a1 MK |
72 | A successful call can legitimately return \-1. |
73 | To detect an error, set | |
74 | .I errno | |
75 | to 0 before the call, and check whether it is nonzero after | |
76 | .BR nice () | |
77 | returns \-1. | |
fea681da MK |
78 | .SH ERRORS |
79 | .TP | |
80 | .B EPERM | |
81 | The calling process attempted to increase its priority by | |
82 | supplying a negative | |
0daa9e92 | 83 | .I inc |
fea681da | 84 | but has insufficient privileges. |
eb9a0b2f | 85 | Under Linux, the |
fea681da MK |
86 | .B CAP_SYS_NICE |
87 | capability is required. | |
c13182ef | 88 | (But see the discussion of the |
8ba10b3e MK |
89 | .B RLIMIT_NICE |
90 | resource limit in | |
91 | .BR setrlimit (2).) | |
47297adb | 92 | .SH CONFORMING TO |
fa8def73 | 93 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. |
32ff4802 | 94 | However, the raw system call and (g)libc |
c8f2dd47 | 95 | (earlier than glibc 2.2.4) return value is nonstandard, see below. |
226f6909 MK |
96 | .\" SVr4 documents an additional |
97 | .\" .B EINVAL | |
98 | .\" error code. | |
fea681da | 99 | .SH NOTES |
dde57ed4 MK |
100 | For further details on the nice value, see |
101 | .BR sched (7). | |
efeece04 | 102 | .PP |
1af83f4a MK |
103 | .IR Note : |
104 | the addition of the "autogroup" feature in Linux 2.6.38 means that | |
105 | the nice value no longer has its traditional effect in many circumstances. | |
106 | For details, see | |
107 | .BR sched (7). | |
32ff4802 MK |
108 | .\" |
109 | .SS C library/kernel differences | |
110 | POSIX.1 specifies that | |
2a019416 MK |
111 | .BR nice () |
112 | should return the new nice value. | |
32ff4802 MK |
113 | However, the raw Linux system call returns 0 on success. |
114 | Likewise, the | |
2a019416 | 115 | .BR nice () |
32ff4802 | 116 | wrapper function provided in glibc 2.2.3 and earlier returns 0 on success. |
efeece04 | 117 | .PP |
32ff4802 | 118 | Since glibc 2.2.4, the |
2a019416 | 119 | .BR nice () |
32ff4802 | 120 | wrapper function provided by glibc provides conformance to POSIX.1 by calling |
2a019416 | 121 | .BR getpriority (2) |
32ff4802 | 122 | to obtain the new nice value, which is then returned to the caller. |
47297adb | 123 | .SH SEE ALSO |
fea681da | 124 | .BR nice (1), |
3e5c319e | 125 | .BR renice (1), |
fea681da MK |
126 | .BR fork (2), |
127 | .BR getpriority (2), | |
52694f09 | 128 | .BR getrlimit (2), |
fea681da | 129 | .BR setpriority (2), |
624a173b MK |
130 | .BR capabilities (7), |
131 | .BR sched (7) |