GETPRIORITY(2) BSD Programmer's Manual GETPRIORITY(2) NNAAMMEE ggeettpprriioorriittyy, sseettpprriioorriittyy - get/set program scheduling priority SSYYNNOOPPSSIISS ##iinncclluuddee <<ssyyss//ttiimmee..hh>> ##iinncclluuddee <<ssyyss//rreessoouurrccee..hh>> _i_n_t ggeettpprriioorriittyy(_i_n_t _w_h_i_c_h, _i_n_t _w_h_o); _i_n_t sseettpprriioorriittyy(_i_n_t _w_h_i_c_h, _i_n_t _w_h_o, _i_n_t _p_r_i_o); DDEESSCCRRIIPPTTIIOONN The scheduling priority of the process, process group, or user, as indi- cated by _w_h_i_c_h and _w_h_o is obtained with the ggeettpprriioorriittyy() call and set with the sseettpprriioorriittyy() call. _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. _P_r_i_o is a value in the range -20 to 20. The default priority is 0; lower priorities cause more favorable scheduling. The ggeettpprriioorriittyy() call returns the highest priority (lowest numerical value) enjoyed by any of the specified processes. The sseettpprriioorriittyy() call sets the priorities of all of the specified processes to the specified value. Only the super-user may lower priorities. RREETTUURRNN VVAALLUUEESS Since ggeettpprriioorriittyy() can legitimately return the value -1, it is necessary to clear the external variable _e_r_r_n_o prior to the call, then check it af- terward to determine if a -1 is an error or a legitimate value. The sseettpprriioorriittyy() call returns 0 if there is no error, or -1 if there is. EERRRROORRSS GGeettpprriioorriittyy() and sseettpprriioorriittyy() will fail if: [ESRCH] No process was located using the _w_h_i_c_h and _w_h_o values spec- ified. [EINVAL] _W_h_i_c_h was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER. In addition to the errors indicated above, sseettpprriioorriittyy() will fail if: [EPERM] A process was located, but neither its effective nor real user ID matched the effective user ID of the caller. [EACCES] A non super-user attempted to lower a process priority. SSEEEE AALLSSOO nice(1), fork(2), renice(8) HHIISSTTOORRYY The ggeettpprriioorriittyy function call appeared in 4.2BSD. 4th Berkeley Distribution June 4, 1993 1