


GETPRIORITY(2)            SYSTEM CALLS             GETPRIORITY(2)



NAME
     getpriority, setpriority - get/set process nice value

SYNOPSIS
     #include <sys/time.h>
     #include <sys/resource.h>

     int getpriority(which, who)
     int which, who;

     int setpriority(which, who, niceval)
     int which, who, niceval;

DESCRIPTION
     The nice value of a process,  process  group,  or  user,  as
     indicated  by  _w_h_i_c_h  and _w_h_o is obtained with the getprior-
     ity() call and set with  the  setpriority()  call.   Process
     nice values can range from -20 through 19.  The default nice
     value is 0; lower nice values cause more favorable  schedul-
     ing.

     _w_h_i_c_h is one of PRIO_PROCESS, PRIO_PGRP, or  PRIO_USER,  and
     _w_h_o  is  interpreted relative to _w_h_i_c_h (a process identifier
     for PRIO_PROCESS, process group  identifier  for  PRIO_PGRP,
     and  a  user ID for PRIO_USER).  A zero value of _w_h_o denotes
     the current process, process group, or user.

     The getpriority() call returns  the  lowest  numerical  nice
     value  of any of the specified processes.  The setpriority()
     call sets the nice values of all of the specified  processes
     to  the value specified by _n_i_c_e_v_a_l.  If _n_i_c_e_v_a_l is less than
     -20, a value of -20 is used; if it is  greater  than  19,  a
     value  of  19 is used.  Only the super-user may use negative
     nice values.

RETURN VALUES
     Since getpriority() can legitimately return the value -1, it
     is  necessary  to clear the external variable errno prior to
     the call, then check it afterward to determine if a -1 is an
     error or a legitimate value.

     setpriority() returns:

     0    on success.

     -1   on failure and sets errno to indicate the error.

ERRORS
     getpriority() and setpriority() may set errno to:

     EINVAL         _w_h_i_c_h was not one of PRIO_PROCESS, PRIO_PGRP,
                    or PRIO_USER.



Sun Release 4.1   Last change: 21 January 1990                  1






GETPRIORITY(2)            SYSTEM CALLS             GETPRIORITY(2)



     ESRCH          No process was located using  the  _w_h_i_c_h  and
                    _w_h_o values specified.

     In addition to the errors indicated above, setpriority() may
     fail with one of the following errors returned:

     EACCES         The call to setpriority() would have  changed
                    a  process'  nice value to a value lower than
                    its current value, and the effective user  ID
                    of  the  process  executing  the call was not
                    that of the super-user.

     EPERM          A process was located, but neither its effec-
                    tive  nor  real user ID matched the effective
                    user ID of the caller, and neither the effec-
                    tive nor the real user ID of the process exe-
                    cuting setpriority() was super-user.

SEE ALSO
     nice(1), ps(1), fork(2V), nice(3v) renice(8)

BUGS
     It is not possible for the process  executing  setpriority()
     to  lower  any other process down to its current nice value,
     without requiring super-user privileges.

     These system calls are misnamed.  They get and set the  nice
     value,   not   the   kernel  scheduling  priority.   nice(1)
     discusses the relationship between nice value and scheduling
     priority.

























Sun Release 4.1   Last change: 21 January 1990                  2



