logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface

Application Usage

       None.

Description

       The nice() function shall add the value of 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.

       A maximum nice value of 2*{NZERO}-1 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.

       Calling the nice() 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.

       The nice value set with nice() shall be applied to the process. If the  process  is  multi-threaded,  the
       nice value shall affect all system scope threads in the process.

       As  -1 is a permissible return value in a successful situation, an application wishing to check for error
       situations should set errno to 0, then call nice(), and if it returns -1, check to see whether  errno  is
       non-zero.

Errors

       The nice() function shall fail if:

       EPERM  The incr argument is negative and the calling process does not have appropriate privileges.

       Thefollowingsectionsareinformative.

Examples

ChangingtheNiceValue
       The following example adds the value of the incr argument, -20, to the nice value of the calling process.

           #include <unistd.h>
           ...
           int incr = -20;
           int ret;

           ret = nice(incr);

Future Directions

       None.

Name

       nice — change the nice value of a process

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.

Rationale

       None.

Return Value

       Upon  successful  completion,  nice()  shall  return the new nice value -{NZERO}.  Otherwise, -1 shall be
       returned, the nice value of the process shall not be changed, and errno shall  be  set  to  indicate  the
       error.

See Also

exec, getpriority()

       The Base Definitions volume of POSIX.1‐2017, <limits.h>, <unistd.h>

Synopsis

       #include <unistd.h>

       int nice(int incr);

See Also