GETRLIMIT(2) RISC/os Reference Manual GETRLIMIT(2)
NAME
getrlimit, setrlimit - control maximum system resource con-
sumption
SYNOPSIS
#include <sys/time.h>
#include <sys/resource.h>
int getrlimit(int resource, struct rlimit *rlp);
int setrlimit(int resource, const struct rlimit *rlp);
DESCRIPTION
Limits on the consumption of a variety of system resources
by a process and each process it creates may be obtained
with getrlimit and set with setrlimit.
Each call to either getrlimit or setrlimit identifies a
specific resource to be operated upon as well as a resource
limit. A resource limit is a pair of values: one specify-
ing the current (soft) limit, the other a maximum (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). Soft limits may
be changed by a process to any value that is less than or
equal to the hard limit. A process may (irreversibly) lower
its hard limit to any value that is greater than or equal to
the soft limit. Only a process with an effective user ID or
superuser can raise a hard limit. Both hard and soft limits
can be changed in a single call to setrlimit subject to the
constraints described above. Limits may have an infinite
value of RLIM_INFINITY. rlp is a pointer to struct rlimit
that includes the following members:
rlim_t rlim_cur; /* current (soft) limit */
rlim_t rlim_max; /* hard limit */
rlim_t is an arithmetic data type to which objects of type
int, size_t, and off_t can be cast without loss of informa-
tion.
The possible resources, their descriptions, and the actions
taken when current limit is exceeded, are summarized in the
following table. Some of the values of these resources are
systype-specific.
Resources Description Action Value
_____________________________________________________________________
RLIMIT_AIOCNT The maximum An attempt to ini- 0x80000001
number of asyn- tiate an asynchro- for -systype
chronous I/O nous I/O request svr4; 8 for
Printed 11/19/92 Page 1
GETRLIMIT(2) RISC/os Reference Manual GETRLIMIT(2)
handles will fail with errno all other
allowed. set to EAGAIN. systypes
RLIMIT_CORE The maximum The writing of a 4
size of a core core file will ter-
file in bytes minate at this size.
that may be
created by a
process. A
limit of 0 will
prevent the
creation of a
core file.
RLIMIT_CPU The maximum SIGXCPU is sent to 0
amount of CPU the process. If the
time in seconds process is holding
used by a pro- or ignoring SIGXCPU,
cess. the behavior is
scheduling class
defined.
RLIMIT_DATA The maximum brk(2) will fail 2
size of a with errno set to
process's heap ENOMEM.
in bytes.
(Continued on next page.)
(Continued from previous page.)
Resources Description Action Value
_____________________________________________________________________
RLIMIT_FSIZE The maximum SIGXFSZ is sent to 1
size of a file the process. If the
in bytes that process is holding
may be created or ignoring SIGXFSZ,
by a process. continued attempts
A limit of 0 to increase the size
will prevent of a file beyond the
the creation of limit will fail with
a file. errno set to EFBIG.
RLIMIT_NOFILE The maximum Functions that 5 for -sys-
number of open create new file type svr4; 7
file descrip- descriptors will for all
tors that the fail with errno set other sys-
process can to EMFILE. types.
have.
RLIMIT_RSS The maximum Imposes a limit on 7 for -sys-
sixe, in bytes, the amount of physi- type svr4; 5
to which a pro- cal memory to be for all
cess' resident given to a process; other sys-
Page 2 Printed 11/19/92
GETRLIMIT(2) RISC/os Reference Manual GETRLIMIT(2)
size may grow. if memory is tight, types
the system will
prefer to take
memory from
processes that are
exceeding their
declared resident
set size.
RLIMIT_STACK The maximum SIGSEGV is sent to 3
size of a the process. If the
process's stack process is holding
in bytes. The or ignoring SIGSEGV,
system will not or is catching SIG-
automatically SEGV and has not
grow the stack made arrangements to
beyond this use an alternate
limit. stack [see
sigaltstack(2)], the
disposition of SIG-
SEGV will be set to
SIG_DFL before it is
sent.
RLIMIT_VMEM The maximum brk(2) and mmap(2) 6
size of a functions will fail
process's with errno set to
mapped address ENOMEM. In addi-
space in bytes. tion, the automatic
stack growth will
fail with the
effects outlined
above.
Because limit information is stored in the per-process
information, the shell builtin ulimit must directly execute
this system call if it is to affect all future processes
created by the shell. See sh(1), csh(1), ksh(1).
The value of the current limit of the following resources
affect these implementation defined constants:
Limit___________Implementation_Defined_Constant
RLIMIT_FSIZE FCHR_MAX
RLIMIT_NOFILE OPEN_MAX
RETURN VALUE
Upon successful completion, the function getrlimit returns a
value of 0; otherwise, it returns a value of -1 and sets
errno to indicate an error.
Printed 11/19/92 Page 3
GETRLIMIT(2) RISC/os Reference Manual GETRLIMIT(2)
ERRORS
Under the following conditions, the functions getrlimit and
setrlimit fail and set errno to:
EFAULT
if the address specified for rlp is invalid.
EINVAL
if an invalid resource was specified; or in a setrlimit
call, the new rlim_cur exceeds the new rlim_max.
EPERM
if the limit specified to setrlimit would have raised
the maximum limit value, and the caller is the
superuser.
FILES
/usr/include/sys/resource.h
SEE ALSO
malloc(3C), open(2), sigaltstack(2), signal(5), quota(2),
sigvec(2), sigstack(2), csh(1), sh(1), ksh(1).
Page 4 Printed 11/19/92