NICE(3)                    POSIX Programmer's Manual                   NICE(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       nice -- change the nice value of a process

SSYYNNOOPPSSIISS
       #include <unistd.h>

       int nice(int _i_n_c_r);

DDEESSCCRRIIPPTTIIOONN
       The _n_i_c_e() function shall add the value of _i_n_c_r 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 _n_i_c_e() 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 _n_i_c_e() 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 _e_r_r_n_o to
       0, then call _n_i_c_e(), and if it returns -1, check to see whether _e_r_r_n_o
       is non-zero.

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

EERRRROORRSS
       The _n_i_c_e() function shall fail if:

       EEPPEERRMM  The _i_n_c_r argument is negative and the calling process does not
              have appropriate privileges.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   CChhaannggiinngg tthhee NNiiccee VVaalluuee
       The following example adds the value of the _i_n_c_r argument, -20, to the
       nice value of the calling process.


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

           ret = nice(incr);

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _e_x_e_c, _g_e_t_p_r_i_o_r_i_t_y()

       The Base Definitions volume of POSIX.1-2017, <<lliimmiittss..hh>>, <<uunniissttdd..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  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.opengroup.org/unix/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 .



IEEE/The Open Group                  2017                              NICE(3)
