]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/nice.2
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man2 / nice.2
CommitLineData
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.\"
cc4615cc 31.TH NICE 2 2007-07-26 "Linux" "Linux Programmer's Manual"
fea681da
MK
32.SH NAME
33nice \- change process priority
34.SH SYNOPSIS
35.B #include <unistd.h>
36.sp
37.BI "int nice(int " inc );
cc4615cc
MK
38.sp
39.in -4n
40Feature Test Macro Requirements for glibc (see
41.BR feature_test_macros (7)):
42.in
43.sp
4e3b3468 44.BR nice ():
cc4615cc 45_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE
fea681da 46.SH DESCRIPTION
2a019416 47.BR nice ()
c13182ef 48adds
fea681da 49.I inc
e360c3a9 50to the nice value for the calling process.
70cbdedf 51(A higher nice value means a low priority.)
c13182ef 52Only the super\%user may specify a negative increment,
70cbdedf 53or priority increase.
7d5b6eb8
MK
54The range for nice values is described in
55.BR getpriority (2).
47297adb 56.SH RETURN VALUE
2a019416
MK
57On success, the new nice value is returned (but see NOTES below).
58On error, \-1 is returned, and
fea681da
MK
59.I errno
60is set appropriately.
61.SH ERRORS
62.TP
63.B EPERM
64The calling process attempted to increase its priority by
65supplying a negative
0daa9e92 66.I inc
fea681da
MK
67but has insufficient privileges.
68Under Linux the
69.B CAP_SYS_NICE
70capability is required.
c13182ef 71(But see the discussion of the
8ba10b3e
MK
72.B RLIMIT_NICE
73resource limit in
74.BR setrlimit (2).)
47297adb 75.SH CONFORMING TO
c13182ef 76SVr4, 4.3BSD, POSIX.1-2001.
97c1eac8 77However, the Linux and (g)libc
c8f2dd47 78(earlier than glibc 2.2.4) return value is nonstandard, see below.
682edefb 79SVr4 documents an additional
0daa9e92 80.B EINVAL
682edefb 81error code.
fea681da 82.SH NOTES
97c1eac8 83SUSv2 and POSIX.1-2001 specify that
2a019416
MK
84.BR nice ()
85should return the new nice value.
86However, the Linux syscall and the
87.BR nice ()
42eda4ae 88library function provided in older versions of (g)libc
2a019416 89(earlier than glibc 2.2.4) return 0 on success.
42eda4ae 90The new nice value can be found using
fea681da 91.BR getpriority (2).
2a019416
MK
92
93Since glibc 2.2.4,
94.BR nice ()
95is implemented as a library function that calls
96.BR getpriority (2)
42eda4ae 97to obtain the new nice value to be returned to the caller.
2a019416 98With this implementation,
84d60f79 99a successful call can legitimately return \-1.
fea681da
MK
100To reliably detect an error, set
101.I errno
102to 0 before the call, and check its value when
2a019416 103.BR nice ()
fea681da 104returns \-1.
47297adb 105.SH SEE ALSO
fea681da 106.BR nice (1),
3e5c319e 107.BR renice (1),
fea681da
MK
108.BR fork (2),
109.BR getpriority (2),
110.BR setpriority (2),
3e5c319e 111.BR capabilities (7)