1
0
Files
irix-657m-src/eoe/man/man2/getrlimit.2
2022-09-29 17:59:04 +03:00

276 lines
7.7 KiB
Groff

'\"! tbl | mmdoc
'\"macro stdmacro
.if n .pH g2.getrlimit @(#)getrlimit 41.4 of 5/26/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.\" ident "@(#)svid_ba:ba_os/getrlimit 1.15"
.\" @(#)getrlimit 1.4 88/09/26 SMI; from UCB 4.3
'\" macro stdmacro
.\" Sun's getrlimit.2
.nr X
.if \nX=0 .ds x} getrlimit 2 "" "\&"
.if \nX=1 .ds x} getrlimit 2 ""
.if \nX=2 .ds x} getrlimit 2 "" "\&"
.if \nX=3 .ds x} getrlimit "" "" "\&"
.TH \*(x}
.SH NAME
getrlimit, getrlimit64, setrlimit, setrlimit64 \- control maximum system resource consumption
.SH SYNOPSIS
.B "#include <sys/resource.h>"
.sp
.B "int getrlimit(int resource, struct rlimit \(**rlp);"
.sp
.B "int getrlimit64(int resource, struct rlimit64 \(**rlp);"
.sp
.B "int setrlimit(int resource, const struct rlimit \(**rlp);"
.sp
.B "int setrlimit64(int resource, const struct rlimit64 \(**rlp);"
.SH DESCRIPTION
Limits on the consumption of a variety of system resources by a process
and each process it creates may be obtained with
\f4getrlimit\fP
and set with
\f4setrlimit\fP.
.P
\f4getrlimit64\fP
and
\f4setrlimit64\fP
allow 32-bit programs to set 64-bit limits. This is particularly useful
for shells and other 32-bit programs which fork 64-bit binaries. Unless
otherwise specified,
\f4getrlimit64\fP
and
\f4setrlimit64\fP
function in exactly the same manner as
\f4getrlimit\fP
and
\f4setrlimit\fP.
.P
Each call to either
\f4getrlimit\fP
or
\f4setrlimit\fP
identifies a specific resource to be operated upon as well as a
resource limit.
A resource limit
is a pair of values: one specifying the current
(soft) limit, the other a maximum
(hard) 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.
.P
Only a the super-user can raise a hard limit.
.P
Both hard and soft limits can be changed in a single call to
\f4setrlimit\fP subject to the constraints described above.
.P
\f4getrlimit64\fP
and
\f4setrlimit64\fP
are provided to allow 32 bit applications to manipulate 64 bit limit
values. For example, the \f4RLIMIT_FSIZE\fP can be set as large as 0xffffffffff
with
\f4setrlimit64\fP
when using the xfs filesystem.
.P
When using the 32 bit interfaces, limits may have an \(lqinfinite\(rq value of
\f4RLIM_INFINITY\fP
(0x7fffffff). In this case
\f2rlp\f1
is a pointer to
\f2struct\fP
\f2rlimit\fP
that includes the following members:
.sp .5
.ft 4
.ta .5i 1.25i 2.25i
.nf
rlim_t rlim_cur; /* current (soft) limit */
rlim_t rlim_max; /* hard limit */
.ft 1
.fi
.P
\f2rlim_t\fP is an arithmetic data type to which objects of type
\f2int\fP, \f2size_t\fP, and \f2off_t\fP can be cast without loss of information.
Specifying the
\f4RLIM_INFINITY\fP
value as the limit in a
\f4setrlimit\fP
call may allow the value of the resource to exceed 0x7fffffff. This is
because specifying \f4RLIM_INFINITY\fP as the limit indicates to the system
to use no limit other than that imposed by the operating system.
When
\f4getrlimit\fP
is used to retrieve a limit which has a value greater
than that which can be represented by an \f2rlim_t\fP, the value returned is the
maximum value representable by an \f2rlim_t\fP.
This value is currently \f4UINT_MAX\fP.
.P
When using the 64 bit interfaces, limits may have an \(lqinfinite\(rq
value of
\f4RLIM64_INFINITY\fP
(0x7fffffffffffffff). In this case
\f2rlp\f1
is a pointer to
\f2struct\fP
\f2rlimit64\fP
that includes the following members:
.sp .5
.ft 4
.ta .5i 1.25i 2.25i
.nf
rlim64_t rlim_cur; /* current (soft) limit */
rlim64_t rlim_max; /* hard limit */
.ft 1
.fi
.P
\f2rlim64_t\fP is an arithmetic data type to which objects of type
\f2long long\fP and \f2off64_t\fP can be cast without loss of information.
.P
The possible resources, their descriptions, and the actions taken
when current limit is exceeded, are summarized below:
.TP 17
.SM
.B RLIMIT_CORE
The maximum size of a core file in bytes
that may be created by a process.
A limit of \f20\fP will prevent the creation of
a core file. The writing of a core file
will terminate at this size.
.TP 17
.SM
.B RLIMIT_CPU
The maximum amount of CPU
time in seconds used by a process.
\f4SIGXCPU\fP is sent to a process which exceeds this limit.
If the process is holding or ignoring
\f4SIGXCPU\fP, the behavior is scheduling
class defined. Unless the \f4SVR4_SIGNALS\fP variable in
\f4/etc/default/login\fP is set to NO, this signal
will be ignored by default.
.TP 17
.SM
.B RLIMIT_DATA
The maximum size of a process's heap in
bytes.
A \f4brk\fP(2) which attempts to exceed this limit will fail
with errno set to \f4ENOMEM\fP.
.TP 17
.SM
.B RLIMIT_FSIZE
The maximum size of a file in bytes that
may be created by a process.
A limit of \f20\fP will prevent the
creation of a file.
A process which attempts to exceed this limit will fail with errno set to
\f4SIGXFSZ\fP.
If the process is holding or ignoring
\f4SIGXFSZ\fP, continued attempts
to increase the size of a file beyond
the limit will fail with errno set
to \f4EFBIG\fP. Unless the \f4SVR4_SIGNALS\fP variable in
\f4/etc/default/login\fP is set to NO, this signal
will be ignored by default.
.TP 17
.SM
.B RLIMIT_NOFILE
The maximum number of open
file descriptors that the
process can have.
Functions that attempt to create new
file descriptors beyond this limit will fail with errno set
to \f4EMFILE\fP.
.TP 17
.SM
.B RLIMIT_STACK
The maximum size of a process's
stack in bytes.
\f4SIGSEGV\fP is sent to a process which attempts to exceed this limit.
If the process is holding or ignoring \f4SIGSEGV\fP, or is
catching \f4SIGSEGV\fP and has not made
arrangements to use an alternate stack
[see \f4sigaltstack\fP(2)],
the disposition of \f4SIGSEGV\fP will be set to \f4SIG_DFL\fP
before it is sent.
This value is used as the default stacksize by \f4sproc\fP(2).
.TP 17
.SM
.B RLIMIT_VMEM
The maximum size of a process's mapped
address space in bytes.
\f4brk\fP(2) and \f4mmap\fP(2) functions which attempt to exceed this limit
will fail with errno set to \f4ENOMEM\fP.
In addition, the automatic stack
growth will fail with the effects
outlined above.
.TP 17
.SM
.B RLIMIT_RSS
The maximum size, in bytes to which a
process's resident set size may grow.
This imposes a limit 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 that are exceeding their declared
resident set size.
.TP 17
.SM
.B RLIMIT_PTHREAD
The maximum number of threads (\f4pthreads\fP(5)) that a process
may create.
Functions that attempt to create new
threads beyond this limit will fail with the error \f4EAGAIN\fP.
.PP
.br
.ne 3
.P
Because limit information is stored in the per-process information,
the shell builtin \f4ulimit\fP must directly execute this system
call if it is to affect all future processes created by the shell;
limit is thus a built-in command to \f4sh(1)\fP and \f4csh(1)\fP.
.P
The value of the current limit of the following resources
affect these implementation defined constants:
.TS
center;
l l
lfCW lfCW.
Limit Implementation Defined Constant
_
RLIMIT_NOFILE OPEN_MAX
.TE
.SH RETURN VALUE
Upon successful completion, the function
\f4getrlimit\fP returns a value of \f20\fP;
otherwise, it returns a value of \f2\-1\fP and sets
\f2errno\fP to indicate an error.
.SH ERRORS
Under the following conditions, the functions
\f4getrlimit\fP and \f4setrlimit\fP fail and
set \f2errno\fP to:
.TP 15
.SM
\%[EFAULT]
The address specified for \f2rlp\fP in invalid.
.TP 15
.SM
\%[EINVAL]
if an invalid \f2resource\fP
was specified; or in a
\f4setrlimit\fP
call, the new
\f2rlim_cur\fP
exceeds the new
\f2rlim_max\fP.
.TP 15
.SM
\%[EPERM]
if the limit specified to
\f4setrlimit\fP
would have raised the maximum limit value
and the caller is not the super-user.
.SH "SEE ALSO"
csh(1), sh(1), open(2), sigaltstack(2), malloc(3C), signal(5).