Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

nice(1)

renice(1)

nice(2)

getpriority(2)

NAME

getpriority, setpriority − get and set process priorities

SYNOPSIS

#include <sys/resource.h>

int getpriority(int which, int who);

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

DESCRIPTION

getpriority() returns the priority of the indicated processes. 

setpriority() sets the priority of the indicated processes to priority.

The processes are indicated by which and who, where which can have one of the following values:

PRIO_PROCESS Get or set the priority of the specified process where who is the process ID.  A who of 0 implies the process ID of the calling process. 

PRIO_PGRP Get or set the priority of the specified process group where who is the process-group ID, indicating all processes belonging to that process-group.  A who of 0 implies the process-group ID of the calling process. 

PRIO_USER Get or set the priority of the specified user where who is the user ID, indicating all processes owned by that user.  A who of 0 implies the user ID of the calling process. 

If more than one process is indicated, the priority returned by getpriority() is the smallest valued priority of all the indicated processes, and setpriority() sets the priority of all indicated processes. 

priority is a value between -20 and 20, where smaller values indicate better priorities.  The default priority for a processes is 0, and negative priorities require appropriate privileges. 

RETURN VALUE

On success, getpriority() returns an integer in the range from −20 to 20, and setpriority() returns 0.  Otherwise, both return −1 and set errno to indicate the error.  See WARNINGS below. 

ERRORS

getpriority() and setpriority() fail if any of the following conditions are encountered:

[ESRCH] Processes indicated by which and who cannot be found. 

[EINVAL] which is not one of the choices listed above. 

[EACCES] The calling process does not have access rights to change one or more of the indicated processes.  All processes for which access is allowed are still affected. 

[EPERM] The calling process attempted to change the priority of a process to a negative value without having appropriate privileges. 

WARNINGS

Note that getpriority() can return −1 when it successfully finds a priority of −1, and when it fails.  To determine whether a failure occurred, set errno to 0 before calling getpriority() then examine errno after the call returns. 

AUTHOR

setpriority() and getpriority() were developed by the University of California, Berkeley. 

SEE ALSO

nice(1), renice(1), nice(2). 

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026