Chapter Contents |
Previous |
Next |
setrlimit |
Portability: | UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
USAGE NOTES | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <sys/resource.h> int setrlimit(int resource, const struct rlimit *info);
DESCRIPTION |
The
setrlimit
function defines resource limits for the calling process. Limits are expressed
as a pair of integers, a soft limit and a hard limit. The soft limit controls
the amount of the resource the program is actually allowed to consume, while
the hard limit specifies an upper bound on the soft limit. The soft limit
can be raised up to the hard limit value, but the hard limit can only be raised
by a privileged (superuser) caller.
The
resource
argument
defines the resource to which the limit applies. It should be specified as
one of the symbolic values defined below.
RLIMIT_AS
-
Specifies the maximum size in bytes of the address space for this process.
If the limit is exceeded, memory allocation functions such as
malloc
or
GETMAIN
will be unable to allocate additional memory.
Note: Setting this limit too low could cause the program to be terminated due to
the inability of the library to obtain more stack space.
RLIMIT_CORE
-
Specifies the maximum size in bytes of an UNIX System Services memory dump
(core file) for this process. A limit of
0
will prevent a dump file from being created.
RLIMIT_CPU
-
Specifies the maximum CPU time in seconds allowed for this address space.
When the limit is exceeded, a
SIGXCPU
signal is sent to the process, and a small amount of additional
time is allocated to allow a signal handler to execute.
RLIMIT_DATA
-
Specifies the maximum amount of memory available for data allocation using
malloc
or
calloc
. This limit is not enforced under UNIX
System Services, and an attempt to set the limit lower than
RLIM_INFINITY
will be rejected.
RLIMIT_FSIZE
-
Specifies the maximum file size in bytes allowed for this process. A limit
of
0
will prevent new files
from being created. If an attempt is made to extend a file beyond the limit,
a
SIGXFSZ
signal is sent
to the process. The limit applies only to UNIX System Services HFS files,
not to standard OS/390 data sets.
RLIMIT_NOFILE
-
The maximum number of file descriptors the process may have open. Any attempt
to open a file with a file number above the limit will fail with
errno
set to
EMFILE
.
RLIMIT_STACK
-
The maximum amount of memory available for stack allocation. This limit is
not enforced under UNIX System Services, and an attempt to set the limit lower
than
RLIM_INFINITY
will
be rejected.
The
info
argument
is a pointer to a structure of type
struct rlimit
, which defines the soft and hard limits. The structure
contains the following fields:
RETURN VALUE |
setrlimit
returns
0
if successful,
or
-1
if unsuccessful.
USAGE NOTES |
The
setrlimit
function can only be used with MVS 5.2.2 or a later release.
Note: Resource limits defined by
setrlimit
are propagated to child processes
created by
fork
or
exec
.
RELATED FUNCTIONS |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.