1*61181Sbostic.\" Copyright (c) 1980, 1991, 1993 2*61181Sbostic.\" The Regents of the University of California. All rights reserved. 320117Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520117Smckusick.\" 6*61181Sbostic.\" @(#)getpriority.2 8.1 (Berkeley) 06/04/93 738053Sbostic.\" 847208Scael.Dd 947208Scael.Dt GETPRIORITY 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm getpriority , 1347208Scael.Nm setpriority 1447208Scael.Nd get/set program scheduling priority 1547208Scael.Sh SYNOPSIS 1647208Scael.Fd #include <sys/time.h> 1747208Scael.Fd #include <sys/resource.h> 1847208Scael.Ft int 1947208Scael.Fn getpriority "int which" "int who" 2047208Scael.Ft int 2147208Scael.Fn setpriority "int which" "int who" "int prio" 2247208Scael.Sh DESCRIPTION 2320117SmckusickThe scheduling 2420118Smckusickpriority of the process, process group, or user, as indicated by 2547208Scael.Fa which 2620118Smckusickand 2747208Scael.Fa who 2820118Smckusickis obtained with the 2947208Scael.Fn getpriority 3020118Smckusickcall and set with the 3147208Scael.Fn setpriority 3220118Smckusickcall. 3347208Scael.Fa Which 3447208Scaelis one of 3547208Scael.Dv PRIO_PROCESS , 3647208Scael.Dv PRIO_PGRP , 3747208Scaelor 3847208Scael.Dv PRIO_USER , 3947208Scaeland 4047208Scael.Fa who 4120118Smckusickis interpreted relative to 4247208Scael.Fa which 4347208Scael(a process identifier for 4447208Scael.Dv PRIO_PROCESS , 4547208Scaelprocess group 4647208Scaelidentifier for 4747208Scael.Dv PRIO_PGRP , 4847208Scaeland a user ID for 4947208Scael.Dv PRIO_USER ) . 5022361SlepreauA zero value of 5147208Scael.Fa who 5222361Slepreaudenotes the current process, process group, or user. 5347208Scael.Fa Prio 5447208Scaelis a value in the range -20 to 20. The default priority is 0; 5520118Smckusicklower priorities cause more favorable scheduling. 5647208Scael.Pp 5720118SmckusickThe 5847208Scael.Fn getpriority 5920118Smckusickcall returns the highest priority (lowest numerical value) 6020118Smckusickenjoyed by any of the specified processes. The 6147208Scael.Fn setpriority 6220118Smckusickcall sets the priorities of all of the specified processes 6320118Smckusickto the specified value. Only the super-user may lower priorities. 6447208Scael.Sh RETURN VALUES 6520118SmckusickSince 6647208Scael.Fn getpriority 6747208Scaelcan legitimately return the value -1, it is necessary 6847208Scaelto clear the external variable 6947208Scael.Va errno 7047208Scaelprior to the 7120118Smckusickcall, then check it afterward to determine 7247208Scaelif a -1 is an error or a legitimate value. 7320118SmckusickThe 7447208Scael.Fn setpriority 7520118Smckusickcall returns 0 if there is no error, or 7647208Scael-1 if there is. 7747208Scael.Sh ERRORS 7847208Scael.Fn Getpriority 7920118Smckusickand 8047208Scael.Fn setpriority 8147208Scaelwill fail if: 8247208Scael.Bl -tag -width Er 8347208Scael.It Bq Er ESRCH 8428081SkarelsNo process was located using the 8547208Scael.Fa which 8620118Smckusickand 8747208Scael.Fa who 8820118Smckusickvalues specified. 8947208Scael.It Bq Er EINVAL 9047208Scael.Fa Which 9147208Scaelwas not one of 9247208Scael.Dv PRIO_PROCESS , 9347208Scael.Dv PRIO_PGRP , 9447208Scaelor 9547208Scael.Dv PRIO_USER . 9647208Scael.El 9747208Scael.Pp 9847208Scael.Bl -tag -width Er 9920118SmckusickIn addition to the errors indicated above, 10047208Scael.Fn setpriority 10147208Scaelwill fail if: 10247208Scael.It Bq Er EPERM 10320118SmckusickA process was located, but neither its effective nor real user 10420118SmckusickID matched the effective user ID of the caller. 10547208Scael.It Bq Er EACCES 10628081SkarelsA non super-user attempted to lower a process priority. 10747208Scael.El 10847208Scael.Sh SEE ALSO 10947208Scael.Xr nice 1 , 11047208Scael.Xr fork 2 , 11147208Scael.Xr renice 8 11247208Scael.Sh HISTORY 11347208ScaelThe 11447208Scael.Nm 11547208Scaelfunction call appeared in 11647208Scael.Bx 4.2 . 117