⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getrlimit.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>getrlimit</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="getrlimit"></a> <a name="tag_03_246"></a><!-- getrlimit --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_246_01"></a>NAME</h4><blockquote>getrlimit, setrlimit - control maximum resource consumption</blockquote><h4><a name="tag_03_246_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include &lt;<a href="../basedefs/sys/resource.h.html">sys/resource.h</a>&gt;<br><br> int getrlimit(int</tt> <i>resource</i><tt>, struct rlimit *</tt><i>rlp</i><tt>);<br> int setrlimit(int</tt> <i>resource</i><tt>, const struct rlimit *</tt><i>rlp</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_246_03"></a>DESCRIPTION</h4><blockquote><p>The <i>getrlimit</i>() function shall get, and the <i>setrlimit</i>() function shall set, limits on the consumption of a varietyof resources.</p><p>Each call to either <i>getrlimit</i>() or <i>setrlimit</i>() identifies a specific resource to be operated upon as well as aresource limit. A resource limit is represented by an <b>rlimit</b> structure. The <i>rlim_cur</i> member specifies the current orsoft limit and the <i>rlim_max</i> member specifies the maximum or hard limit. Soft limits may be changed by a process to any valuethat is less than or equal to the hard limit. A process may (irreversibly) lower its hard limit to any value that is greater thanor equal to the soft limit. Only a process with appropriate privileges can raise a hard limit. Both hard and soft limits can bechanged in a single call to <i>setrlimit</i>() subject to the constraints described above.</p><p>The value RLIM_INFINITY, defined in <a href="../basedefs/sys/resource.h.html"><i>&lt;sys/resource.h&gt;</i></a>, shall beconsidered to be larger than any other limit value. If a call to <i>getrlimit</i>() returns RLIM_INFINITY for a resource, it meansthe implementation shall not enforce limits on that resource. Specifying RLIM_INFINITY as any resource limit value on a successfulcall to <i>setrlimit</i>() shall inhibit enforcement of that resource limit.</p><p>The following resources are defined:</p><dl compact><dt>RLIMIT_CORE</dt><dd>This is the maximum size of a <b>core</b> file, in bytes, that may be created by a process. A limit of 0 shall prevent thecreation of a <b>core</b> file. If this limit is exceeded, the writing of a <b>core</b> file shall terminate at this size.</dd><dt>RLIMIT_CPU</dt><dd>This is the maximum amount of CPU time, in seconds, used by a process. If this limit is exceeded, SIGXCPU shall be generatedfor the process. If the process is catching or ignoring SIGXCPU, or all threads belonging to that process are blocking SIGXCPU, thebehavior is unspecified.</dd><dt>RLIMIT_DATA</dt><dd>This is the maximum size of a process' data segment, in bytes. If this limit is exceeded, the <a href="../functions/malloc.html"><i>malloc</i>()</a> function shall fail with <i>errno</i> set to [ENOMEM].</dd><dt>RLIMIT_FSIZE</dt><dd>This is the maximum size of a file, in bytes, that may be created by a process. If a write or truncate operation would causethis limit to be exceeded, SIGXFSZ shall be generated for the thread. If the thread is blocking, or the process is catching orignoring SIGXFSZ, continued attempts to increase the size of a file from end-of-file to beyond the limit shall fail with<i>errno</i> set to [EFBIG].</dd><dt>RLIMIT_NOFILE</dt><dd>This is a number one greater than the maximum value that the system may assign to a newly-created descriptor. If this limit isexceeded, functions that allocate a file descriptor shall fail with <i>errno</i> set to [EMFILE]. This limit constrains the numberof file descriptors that a process may allocate.</dd><dt>RLIMIT_STACK</dt><dd>This is the maximum size of a process' stack, in bytes. The implementation does not automatically grow the stack beyond thislimit. If this limit is exceeded, SIGSEGV shall be generated for the thread. If the thread is blocking SIGSEGV, or the process isignoring or catching SIGSEGV and has not made arrangements to use an alternate stack, the disposition of SIGSEGV shall be set toSIG_DFL before it is generated.</dd><dt>RLIMIT_AS</dt><dd>This is the maximum size of a process' total available memory, in bytes. If this limit is exceeded, the <a href="../functions/malloc.html"><i>malloc</i>()</a> and <a href="../functions/mmap.html"><i>mmap</i>()</a> functions shall fail with<i>errno</i> set to [ENOMEM]. In addition, the automatic stack growth fails with the effects outlined above.</dd></dl><p>When using the <i>getrlimit</i>() function, if a resource limit can be represented correctly in an object of type <b>rlim_t</b>,then its representation is returned; otherwise, if the value of the resource limit is equal to that of the corresponding saved hardlimit, the value returned shall be RLIM_SAVED_MAX; otherwise, the value returned shall be RLIM_SAVED_CUR.</p><p>When using the <i>setrlimit</i>() function, if the requested new limit is RLIM_INFINITY, the new limit shall be &quot;no limit'';otherwise, if the requested new limit is RLIM_SAVED_MAX, the new limit shall be the corresponding saved hard limit; otherwise, ifthe requested new limit is RLIM_SAVED_CUR, the new limit shall be the corresponding saved soft limit; otherwise, the new limitshall be the requested value. In addition, if the corresponding saved limit can be represented correctly in an object of type<b>rlim_t</b> then it shall be overwritten with the new limit.</p><p>The result of setting a limit to RLIM_SAVED_MAX or RLIM_SAVED_CUR is unspecified unless a previous call to <i>getrlimit</i>()returned that value as the soft or hard limit for the corresponding resource limit.</p><p>The determination of whether a limit can be correctly represented in an object of type <b>rlim_t</b> is implementation-defined.For example, some implementations permit a limit whose value is greater than RLIM_INFINITY and others do not.</p><p>The <i><a href="../functions/exec.html">exec</a></i> family of functions shall cause resource limits to be saved.</p></blockquote><h4><a name="tag_03_246_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>getrlimit</i>() and <i>setrlimit</i>() shall return 0. Otherwise, these functions shall return -1and set <i>errno</i> to indicate the error.</p></blockquote><h4><a name="tag_03_246_05"></a>ERRORS</h4><blockquote><p>The <i>getrlimit</i>() and <i>setrlimit</i>() functions shall fail if:</p><dl compact><dt>[EINVAL]</dt><dd>An invalid <i>resource</i> was specified; or in a <i>setrlimit</i>() call, the new <i>rlim_cur</i> exceeds the new<i>rlim_max</i>.</dd><dt>[EPERM]</dt><dd>The limit specified to <i>setrlimit</i>() would have raised the maximum limit value, and the calling process does not haveappropriate privileges.</dd></dl><p>The <i>setrlimit</i>() function may fail if:</p><dl compact><dt>[EINVAL]</dt><dd>The limit specified cannot be lowered because current usage is already higher than the limit.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_246_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_246_07"></a>APPLICATION USAGE</h4><blockquote><p>If a process attempts to set the hard limit or soft limit for RLIMIT_NOFILE to less than the value of {_POSIX_OPEN_MAX} from <ahref="../basedefs/limits.h.html"><i>&lt;limits.h&gt;</i></a>, unexpected behavior may occur.</p><p>If a process attempts to set the hard limit or soft limit for RLIMIT_NOFILE to less than the highest currently open filedescriptor +1, unexpected behavior may occur.</p></blockquote><h4><a name="tag_03_246_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_246_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_246_10"></a>SEE ALSO</h4><blockquote><p><a href="exec.html"><i><a href="../functions/exec.html">exec</a></i>()</a> , <a href="fork.html"><i>fork</i>()</a> , <a href="malloc.html"><i>malloc</i>()</a> , <a href="open.html"><i>open</i>()</a> , <a href="sigaltstack.html"><i>sigaltstack</i>()</a> ,<a href="sysconf.html"><i>sysconf</i>()</a> , <a href="ulimit.html"><i>ulimit</i>()</a> , the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/stropts.h.html"><i>&lt;stropts.h&gt;</i></a>, <a href="../basedefs/sys/resource.h.html"><i>&lt;sys/resource.h&gt;</i></a></p></blockquote><h4><a name="tag_03_246_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_246_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE.</p><p>An APPLICATION USAGE section is added.</p><p>Large File Summit extensions are added.</p></blockquote><h4><a name="tag_03_246_13"></a>Issue 6</h4><blockquote><p>IEEE&nbsp;Std 1003.1-2001/Cor&nbsp;1-2002, item XSH/TC1/D6/25 is applied, changing wording for RLIMIT_NOFILE in the DESCRIPTIONrelated to functions that allocate a file descriptor failing with [EMFILE]. Text is added to the APPLICATION USAGE section notingthe consequences of a process attempting to set the hard or soft limit for RLIMIT_NOFILE less than the highest currently open filedescriptor +1.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -