Blob Blame History Raw
'\" et
.TH NICE "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.

.SH NAME
nice
\(em change the nice value of a process
.SH SYNOPSIS
.LP
.nf
#include <unistd.h>
.P
int nice(int \fIincr\fP);
.fi
.SH DESCRIPTION
The
\fInice\fR()
function shall add the value of
.IR incr
to the nice value of the calling process. A nice value of a process is
a non-negative number for which a more positive value shall result in
less favorable scheduling.
.P
A maximum nice value of 2*{NZERO}\(mi1 and a minimum nice value of 0
shall be imposed by the system. Requests for values above or below
these limits shall result in the nice value being set to the
corresponding limit. Only a process with appropriate privileges can
lower the nice value.
.P
Calling the
\fInice\fR()
function has no effect on the priority of processes or threads with
policy SCHED_FIFO or SCHED_RR.
The effect on processes or threads with other scheduling policies is
implementation-defined.
.P
The nice value set with
\fInice\fR()
shall be applied to the process. If the process is multi-threaded,
the nice value shall affect all system scope threads in the process.
.P
As \(mi1 is a permissible return value in a successful situation, an
application wishing to check for error situations should set
.IR errno
to 0, then call
\fInice\fR(),
and if it returns \(mi1, check to see whether
.IR errno
is non-zero.
.SH "RETURN VALUE"
Upon successful completion,
\fInice\fR()
shall return the new nice value \(mi{NZERO}.
Otherwise, \(mi1 shall be returned, the nice value of the process
shall not be changed, and
.IR errno
shall be set to indicate the error.
.SH ERRORS
The
\fInice\fR()
function shall fail if:
.TP
.BR EPERM
The
.IR incr
argument is negative and the calling process does not have appropriate
privileges.
.LP
.IR "The following sections are informative."
.SH EXAMPLES
.SS "Changing the Nice Value"
.P
The following example adds the value of the
.IR incr
argument, \(mi20, to the nice value of the calling process.
.sp
.RS 4
.nf
\fB
#include <unistd.h>
\&...
int incr = -20;
int ret;
.P
ret = nice(incr);
.fi \fR
.P
.RE
.SH "APPLICATION USAGE"
None.
.SH RATIONALE
None.
.SH "FUTURE DIRECTIONS"
None.
.SH "SEE ALSO"
.IR "\fIexec\fR\^",
.IR "\fIgetpriority\fR\^(\|)"
.P
The Base Definitions volume of POSIX.1\(hy2008,
.IR "\fB<limits.h>\fP",
.IR "\fB<unistd.h>\fP"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group.
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.unix.org/online.html .

Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .