260 lines
6.5 KiB
HTML
260 lines
6.5 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>getrlimit()--Get resource limit</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- Edited by Kersten Jan 02 -->
|
||
|
<!-- This file has undergone html cleanup July 2002 by JET -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!-- Java sync-link -->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>getrlimit()--Get resource limit</h2>
|
||
|
|
||
|
<div class="box" style="width: 80%;">
|
||
|
<br>
|
||
|
Syntax
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/resource.h>
|
||
|
|
||
|
int getrlimit(int <em>resource</em>, struct rlimit *<em>rlp</em>);
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QP0WSRV1<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Yes<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>getrlimit()</strong> function returns the resource limit for the
|
||
|
specified <em>resource</em>. A resource limit is a way for the operating system
|
||
|
to enforce a limit on a variety of resources used by a process. A resource
|
||
|
limit is represented by a rlimit structure. The rlim_cur member specifies the
|
||
|
current or soft limit and the rlim_max member specifies the maximum or hard
|
||
|
limit.</p>
|
||
|
|
||
|
<p>The <strong>getrlimit()</strong> function supports the following
|
||
|
resources:</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="20 80" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_FSIZE (0)</em></td>
|
||
|
<td align="left" valign="top">The maximum size of a file in bytes that can be
|
||
|
created by a process.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_NOFILE (1)</em></td>
|
||
|
<td align="left" valign="top">The maximum number of file descriptors that can
|
||
|
be opened by a process.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_CORE (2)</em></td>
|
||
|
<td align="left" valign="top">The maximum size of a core file in bytes that can
|
||
|
be created by a process.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_CPU (3)</em></td>
|
||
|
<td align="left" valign="top">The maximum amount of CPU time in seconds that
|
||
|
can be used by a process.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_DATA (4)</em></td>
|
||
|
<td align="left" valign="top">The maximum size of a process' data segment in
|
||
|
bytes.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_STACK (5)</em></td>
|
||
|
<td align="left" valign="top">The maximum size of a process' stack in
|
||
|
bytes.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>RLIMIT_AS (6)</em></td>
|
||
|
<td align="left" valign="top">The maximum size of a process' total available
|
||
|
storage in bytes.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>The value of RLIM_INFINITY is considered to be larger than any other limit
|
||
|
value. If the value of the limit is RLIM_INFINITY, then a limit is not enforced
|
||
|
for that resource. The <strong>getrlimit()</strong> function always returns
|
||
|
RLIM_INFINITY for the following resources: RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU,
|
||
|
RLIMIT_DATA, and RLIMIT_STACK.</p>
|
||
|
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong><em>resource</em></strong></dt>
|
||
|
|
||
|
<dd>(Input)
|
||
|
|
||
|
<p>The resource to get the limits for.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>*<em>rlp</em></strong></dt>
|
||
|
|
||
|
<dd>(Output)
|
||
|
|
||
|
<p>Pointer to a struct rlim_t where the values of the hard and soft limits are
|
||
|
returned.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<h3>Authorities and Locks</h3>
|
||
|
|
||
|
<p>None.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="5 95" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><strong>0</strong></td>
|
||
|
<td align="left" valign="top"><strong>getrlimit()</strong> was successful.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top" nowrap><strong>-1</strong></td>
|
||
|
<td align="left" valign="top"><strong>getrlimit()</strong> was not successful.
|
||
|
The <em>errno</em> variable is set to indicate the error.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>getrlimit()</strong> is not successful, <em>errno</em> usually
|
||
|
indicates one of the following errors. Under some conditions, <em>errno</em>
|
||
|
could indicate an error other than those listed here.</p>
|
||
|
|
||
|
<dl>
|
||
|
<dt><em>[EFAULT]</em></dt>
|
||
|
|
||
|
<dd>
|
||
|
<p>The address used for an argument is not correct.</p>
|
||
|
|
||
|
<p>In attempting to use an argument in a call, the system detected an address
|
||
|
that is not valid.</p>
|
||
|
|
||
|
<p>While attempting to access a parameter passed to this function, the system
|
||
|
detected an address that is not valid.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><em>[EINVAL]</em></dt>
|
||
|
|
||
|
<dd>
|
||
|
<p>An invalid parameter was found.</p>
|
||
|
|
||
|
<p>An invalid <em>resource</em> was specified.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>sys/resource.h</strong>> file (see <a href="unix13.htm">
|
||
|
Header Files for UNIX-Type Functions</a>)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="setrlim.htm">setrlimit()</a>--Set resource limit<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="ulimit.htm">ulimit()</a>--Get and set process limits<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<h3>Example</h3>
|
||
|
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/resource.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <errno.h>
|
||
|
|
||
|
int main (int argc, char *argv[])
|
||
|
{
|
||
|
struct rlimit limit;
|
||
|
|
||
|
/* Set the file size resource limit. */
|
||
|
limit.rlim_cur = 65535;
|
||
|
limit.rlim_max = 65535;
|
||
|
if (setrlimit(RLIMIT_FSIZE, &limit) != 0) {
|
||
|
printf("setrlimit() failed with errno=%d\n", errno);
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
/* Get the file size resource limit. */
|
||
|
if (getrlimit(RLIMIT_FSIZE, &limit) != 0) {
|
||
|
printf("getrlimit() failed with errno=%d\n", errno);
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
printf("The soft limit is %llu\n", limit.rlim_cur);
|
||
|
printf("The hard limit is %llu\n", limit.rlim_max);
|
||
|
exit(0);
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<strong>Example Output:</strong>
|
||
|
|
||
|
<pre>
|
||
|
The soft limit is 65535
|
||
|
The hard limit is 65535
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<hr>
|
||
|
API introduced: V5R2
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|