|
Packit |
7cfc04 |
.\" Copyright (c) 1992 Drew Eckhardt <drew@cs.colorado.edu>, March 28, 1992
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(VERBATIM)
|
|
Packit |
7cfc04 |
.\" Permission is granted to make and distribute verbatim copies of this
|
|
Packit |
7cfc04 |
.\" manual provided the copyright notice and this permission notice are
|
|
Packit |
7cfc04 |
.\" preserved on all copies.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Permission is granted to copy and distribute modified versions of this
|
|
Packit |
7cfc04 |
.\" manual under the conditions for verbatim copying, provided that the
|
|
Packit |
7cfc04 |
.\" entire resulting derived work is distributed under the terms of a
|
|
Packit |
7cfc04 |
.\" permission notice identical to this one.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
Packit |
7cfc04 |
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
Packit |
7cfc04 |
.\" responsibility for errors or omissions, or for damages resulting from
|
|
Packit |
7cfc04 |
.\" the use of the information contained herein. The author(s) may not
|
|
Packit |
7cfc04 |
.\" have taken the same level of care in the production of this manual,
|
|
Packit |
7cfc04 |
.\" which is licensed free of charge, as they might when working
|
|
Packit |
7cfc04 |
.\" professionally.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
Packit |
7cfc04 |
.\" the source, must acknowledge the copyright and authors of this work.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Modified by Michael Haardt <michael@moria.de>
|
|
Packit |
7cfc04 |
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
|
|
Packit |
7cfc04 |
.\" Modified 1996-11-04 by Eric S. Raymond <esr@thyrsus.com>
|
|
Packit |
7cfc04 |
.\" Modified 2001-06-04 by aeb
|
|
Packit |
7cfc04 |
.\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH NICE 2 2017-09-15 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
nice \- change process priority
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.B #include <unistd.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int nice(int " inc );
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in -4n
|
|
Packit |
7cfc04 |
Feature Test Macro Requirements for glibc (see
|
|
Packit |
7cfc04 |
.BR feature_test_macros (7)):
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BR nice ():
|
|
Packit |
7cfc04 |
_XOPEN_SOURCE
|
|
Packit |
7cfc04 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|
|
Packit |
7cfc04 |
|| /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
.BR nice ()
|
|
Packit |
7cfc04 |
adds
|
|
Packit |
7cfc04 |
.I inc
|
|
Packit |
7cfc04 |
to the nice value for the calling thread.
|
|
Packit |
7cfc04 |
(A higher nice value means a low priority.)
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The range of the nice value is +19 (low priority) to \-20 (high priority).
|
|
Packit |
7cfc04 |
Attempts to set a nice value outside the range are clamped to the range.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Traditionally, only a privileged process could lower the nice value
|
|
Packit |
7cfc04 |
(i.e., set a higher priority).
|
|
Packit |
7cfc04 |
However, since Linux 2.6.12, an unprivileged process can decrease
|
|
Packit |
7cfc04 |
the nice value of a target process that has a suitable
|
|
Packit |
7cfc04 |
.BR RLIMIT_NICE
|
|
Packit |
7cfc04 |
soft limit; see
|
|
Packit |
7cfc04 |
.BR getrlimit (2)
|
|
Packit |
7cfc04 |
for details.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
On success, the new nice value is returned (but see NOTES below).
|
|
Packit |
7cfc04 |
On error, \-1 is returned, and
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
is set appropriately.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
A successful call can legitimately return \-1.
|
|
Packit |
7cfc04 |
To detect an error, set
|
|
Packit |
7cfc04 |
.I errno
|
|
Packit |
7cfc04 |
to 0 before the call, and check whether it is nonzero after
|
|
Packit |
7cfc04 |
.BR nice ()
|
|
Packit |
7cfc04 |
returns \-1.
|
|
Packit |
7cfc04 |
.SH ERRORS
|
|
Packit |
7cfc04 |
.TP
|
|
Packit |
7cfc04 |
.B EPERM
|
|
Packit |
7cfc04 |
The calling process attempted to increase its priority by
|
|
Packit |
7cfc04 |
supplying a negative
|
|
Packit |
7cfc04 |
.I inc
|
|
Packit |
7cfc04 |
but has insufficient privileges.
|
|
Packit |
7cfc04 |
Under Linux, the
|
|
Packit |
7cfc04 |
.B CAP_SYS_NICE
|
|
Packit |
7cfc04 |
capability is required.
|
|
Packit |
7cfc04 |
(But see the discussion of the
|
|
Packit |
7cfc04 |
.B RLIMIT_NICE
|
|
Packit |
7cfc04 |
resource limit in
|
|
Packit |
7cfc04 |
.BR setrlimit (2).)
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
|
|
Packit |
7cfc04 |
However, the raw system call and (g)libc
|
|
Packit |
7cfc04 |
(earlier than glibc 2.2.4) return value is nonstandard, see below.
|
|
Packit |
7cfc04 |
.\" SVr4 documents an additional
|
|
Packit |
7cfc04 |
.\" .B EINVAL
|
|
Packit |
7cfc04 |
.\" error code.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
For further details on the nice value, see
|
|
Packit |
7cfc04 |
.BR sched (7).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.IR Note :
|
|
Packit |
7cfc04 |
the addition of the "autogroup" feature in Linux 2.6.38 means that
|
|
Packit |
7cfc04 |
the nice value no longer has its traditional effect in many circumstances.
|
|
Packit |
7cfc04 |
For details, see
|
|
Packit |
7cfc04 |
.BR sched (7).
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SS C library/kernel differences
|
|
Packit |
7cfc04 |
POSIX.1 specifies that
|
|
Packit |
7cfc04 |
.BR nice ()
|
|
Packit |
7cfc04 |
should return the new nice value.
|
|
Packit |
7cfc04 |
However, the raw Linux system call returns 0 on success.
|
|
Packit |
7cfc04 |
Likewise, the
|
|
Packit |
7cfc04 |
.BR nice ()
|
|
Packit |
7cfc04 |
wrapper function provided in glibc 2.2.3 and earlier returns 0 on success.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Since glibc 2.2.4, the
|
|
Packit |
7cfc04 |
.BR nice ()
|
|
Packit |
7cfc04 |
wrapper function provided by glibc provides conformance to POSIX.1 by calling
|
|
Packit |
7cfc04 |
.BR getpriority (2)
|
|
Packit |
7cfc04 |
to obtain the new nice value, which is then returned to the caller.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR nice (1),
|
|
Packit |
7cfc04 |
.BR renice (1),
|
|
Packit |
7cfc04 |
.BR fork (2),
|
|
Packit |
7cfc04 |
.BR getpriority (2),
|
|
Packit |
7cfc04 |
.BR getrlimit (2),
|
|
Packit |
7cfc04 |
.BR setpriority (2),
|
|
Packit |
7cfc04 |
.BR capabilities (7),
|
|
Packit |
7cfc04 |
.BR sched (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|