Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

csh(1)

quota(2)

GETRLIMIT(2)

NAME

getrlimit − control maximum system resource consumption

USAGE

#include <sys/time.h>
#include <sys/resource.h>
getrlimit(resource, rlp)
int resource;
struct rlimit *rlp;

DESCRIPTION

Limits on the consumption of system resources by the current process and each process it creates may be obtained with the getrlimit call. 

The resource parameter is one of the following:

RLIMIT_CPU Maximum amount of CPU time (in milliseconds) to be used by each process. Currently, this is always RLIMIT_INFINITY. 

RLIMIT_FSIZE Largest size, in bytes, of any single file that may be created. 

RLIMIT_DATA Maximum size, in bytes, of the data segment for a process; this defines how far a program may extend its break with the sbrk(2) system call. 

RLIMIT_STACK Maximum size, in bytes, of the stack segment for a process; this defines how far a program’s stack segment may be extended. 

RLIMIT_CORE Largest size, in bytes, of a core file that may be created. Currently, this is always 0. 

RLIMIT_RSS Maximum size, in bytes, to which a process’s resident set size may grow.  Currently, this is always RLIMIT_INFINITY.  A limit is imposed on the amount of physical memory to be given to a process; if memory is tight, the system will prefer to take memory from processes which are exceeding their declared resident set size. 

A resource limit is specified as a soft limit and a hard limit.  When a soft limit is exceeded a process may receive a signal (for example, if the CPU time is exceeded), but it will be allowed to continue execution until it reaches the hard limit (or modifies its resource limit).  The rlimit structure is used to specify the hard and soft limits on a resource, struct rlimit {  int rlim_cur; /* current (soft) limit */  int rlim_max; /* hard limit */ };

An “infinite” value for a limit is defined as RLIMIT_INFINITY (0x7fffffff). 

The system refuses to extend the data or stack space when the limits would be exceeded in the normal way: a break call fails if the data space limit is reached, or the process is killed when the stack limit is reached (since the stack cannot be extended, there is no way to send a signal). 

RETURN VALUE

A 0 return value indicates that the call succeeded.  Otherwise, −1 is returned and an error code is stored in errno. 

ERRORS

[EFAULT] The address specified for rlp is invalid. 

RELATED INFORMATION

csh(1) quota(2)

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