205 lines
5.0 KiB
HTML
205 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of NICE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>NICE</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
nice - change process priority
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/unistd.h">unistd.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int nice(int </B><I>inc</I><B>);</B>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>nice</B>():
|
|
|
|
_XOPEN_SOURCE
|
|
<BR> || /* Since glibc 2.19: */ _DEFAULT_SOURCE
|
|
<BR> || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>nice</B>()
|
|
|
|
adds
|
|
<I>inc</I>
|
|
|
|
to the nice value for the calling thread.
|
|
(A higher nice value means a low priority.)
|
|
<P>
|
|
|
|
The range of the nice value is +19 (low priority) to -20 (high priority).
|
|
Attempts to set a nice value outside the range are clamped to the range.
|
|
<P>
|
|
|
|
Traditionally, only a privileged process could lower the nice value
|
|
(i.e., set a higher priority).
|
|
However, since Linux 2.6.12, an unprivileged process can decrease
|
|
the nice value of a target process that has a suitable
|
|
<B>RLIMIT_NICE</B>
|
|
|
|
soft limit; see
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrlimit">getrlimit</A></B>(2)
|
|
|
|
for details.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, the new nice value is returned (but see NOTES below).
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<P>
|
|
|
|
A successful call can legitimately return -1.
|
|
To detect an error, set
|
|
<I>errno</I>
|
|
|
|
to 0 before the call, and check whether it is nonzero after
|
|
<B>nice</B>()
|
|
|
|
returns -1.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EPERM</B>
|
|
|
|
<DD>
|
|
The calling process attempted to increase its priority by
|
|
supplying a negative
|
|
<I>inc</I>
|
|
|
|
but has insufficient privileges.
|
|
Under Linux, the
|
|
<B>CAP_SYS_NICE</B>
|
|
|
|
capability is required.
|
|
(But see the discussion of the
|
|
<B>RLIMIT_NICE</B>
|
|
|
|
resource limit in
|
|
<B><A HREF="/cgi-bin/man/man2html?2+setrlimit">setrlimit</A></B>(2).)
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
|
|
However, the raw system call and (g)libc
|
|
(earlier than glibc 2.2.4) return value is nonstandard, see below.
|
|
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
For further details on the nice value, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sched">sched</A></B>(7).
|
|
|
|
<P>
|
|
|
|
<I>Note</I>:
|
|
|
|
the addition of the "autogroup" feature in Linux 2.6.38 means that
|
|
the nice value no longer has its traditional effect in many circumstances.
|
|
For details, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sched">sched</A></B>(7).
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>C library/kernel differences</H3>
|
|
|
|
POSIX.1 specifies that
|
|
<B>nice</B>()
|
|
|
|
should return the new nice value.
|
|
However, the raw Linux system call returns 0 on success.
|
|
Likewise, the
|
|
<B>nice</B>()
|
|
|
|
wrapper function provided in glibc 2.2.3 and earlier returns 0 on success.
|
|
<P>
|
|
|
|
Since glibc 2.2.4, the
|
|
<B>nice</B>()
|
|
|
|
wrapper function provided by glibc provides conformance to POSIX.1 by calling
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getpriority">getpriority</A></B>(2)
|
|
|
|
to obtain the new nice value, which is then returned to the caller.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+nice">nice</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+renice">renice</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getpriority">getpriority</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+getrlimit">getrlimit</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+setpriority">setpriority</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+capabilities">capabilities</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sched">sched</A></B>(7)
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="2"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="3"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="4"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="5"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="6"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="7"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="8"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DL>
|
|
<DT id="9"><A HREF="#lbAI">C library/kernel differences</A><DD>
|
|
</DL>
|
|
<DT id="10"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="11"><A HREF="#lbAK">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:33 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|