isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

ulimit.html (15942B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>ulimit</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/type.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/umask.html" accesskey="N">Next
     19 &gt;&gt;&gt;</a></td>
     20 </tr>
     21 </table>
     22 <hr align="left" width="100%"></div>
     23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     24 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     25 IEEE Std 1003.1-2024<br>
     26 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     27 <hr size="2" noshade>
     28 <a name="top" id="top"></a> <a name="ulimit" id="ulimit"></a> <a name="tag_20_131" id="tag_20_131"></a><!-- ulimit -->
     29 <h4 class="mansect"><a name="tag_20_131_01" id="tag_20_131_01"></a>NAME</h4>
     30 <blockquote>ulimit — report or set resource limits</blockquote>
     31 <h4 class="mansect"><a name="tag_20_131_02" id="tag_20_131_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>ulimit</tt> <b>[</b><tt>-H|-S</tt><b>]</b> <tt>-a<br>
     34 <br>
     35 <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> ulimit</tt> <b>[</b><tt>-H|-S</tt><b>] [</b><tt>-c|-d|-f|-n|-s|<img src=
     36 "../images/opt-start.gif" border="0">-t<img src="../images/opt-end.gif" border="0">|-v</tt><b>] [</b><i>newlimit</i><b>]</b>
     37 <tt><br></tt></code></p>
     38 </blockquote>
     39 <h4 class="mansect"><a name="tag_20_131_03" id="tag_20_131_03"></a>DESCRIPTION</h4>
     40 <blockquote>
     41 <p>The <i>ulimit</i> utility shall report or set the resource limits in effect in the process in which it is executed.</p>
     42 <p>Soft limits can be changed by a process to any value that is less than or equal to the hard limit. A process can (irreversibly)
     43 lower its hard limit to any value that is greater than or equal to the soft limit. Only a process with appropriate privileges can
     44 raise a hard limit.</p>
     45 <p>The value <b>unlimited</b> for a resource shall be considered to be larger than any other limit value. When a resource has this
     46 limit value, the implementation shall not enforce limits on that resource. In locales other than the POSIX locale, <i>ulimit</i>
     47 may support additional non-numeric values with the same meaning as <b>unlimited</b>.</p>
     48 <p>The behavior when resource limits are exceeded shall be as described in the System Interfaces volume of POSIX.1-2024 for the
     49 <a href="../functions/setrlimit.html"><i>setrlimit</i>()</a> function.</p>
     50 </blockquote>
     51 <h4 class="mansect"><a name="tag_20_131_04" id="tag_20_131_04"></a>OPTIONS</h4>
     52 <blockquote>
     53 <p>The <i>ulimit</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     54 Guidelines</i></a> , except that:</p>
     55 <ul>
     56 <li>
     57 <p>The order in which options other than <b>-H</b>, <b>-S</b>, and <b>-a</b> are specified may be significant.</p>
     58 </li>
     59 <li>
     60 <p>Conforming applications shall specify each option separately; that is, grouping option letters (for example, <b>-fH</b>) need
     61 not be recognized by all implementations.</p>
     62 </li>
     63 </ul>
     64 <p>The following options shall be supported:</p>
     65 <dl compact>
     66 <dd></dd>
     67 <dt><b>-H</b></dt>
     68 <dd>Report hard limit(s) or set only a hard limit.</dd>
     69 <dt><b>-S</b></dt>
     70 <dd>Report soft limit(s) or set only a soft limit.</dd>
     71 <dt><b>-a</b></dt>
     72 <dd>Report the limit value for all of the resources named below and for any implementation-specific additional resources.</dd>
     73 <dt><b>-c</b></dt>
     74 <dd>Report, or set if the <i>newlimit</i> operand is present, the core image size limit(s) in units of 512 bytes.
     75 [RLIMIT_CORE]</dd>
     76 <dt><b>-d</b></dt>
     77 <dd>Report, or set if the <i>newlimit</i> operand is present, the data segment size limit(s) in units of 1024 bytes.
     78 [RLIMIT_DATA]</dd>
     79 <dt><b>-f</b></dt>
     80 <dd>Report, or set if the <i>newlimit</i> operand is present, the file size limit(s) in units of 512 bytes. [RLIMIT_FSIZE]</dd>
     81 <dt><b>-n</b></dt>
     82 <dd>Report, or set if the <i>newlimit</i> operand is present, the limit(s) on the number of open file descriptors, given as a
     83 number one greater than the maximum value that the system assigns to a newly-created descriptor. [RLIMIT_NOFILE]</dd>
     84 <dt><b>-s</b></dt>
     85 <dd>Report, or set if the <i>newlimit</i> operand is present, the stack size limit(s) in units of 1024 bytes. [RLIMIT_STACK]</dd>
     86 <dt><b>-t</b></dt>
     87 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
     88 Report, or set if the <i>newlimit</i> operand is present, the per-process CPU time limit(s) in units of seconds. [RLIMIT_CPU]
     89 <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
     90 <dt><b>-v</b></dt>
     91 <dd>Report, or set if the <i>newlimit</i> operand is present, the address space size limit(s) in units of 1024 bytes.
     92 [RLIMIT_AS]</dd>
     93 </dl>
     94 <p>Where an option description is followed by [RLIMIT_<i>name</i>] it indicates which resource for the <a href=
     95 "../functions/getrlimit.html"><i>getrlimit</i>()</a> and <a href="../functions/setrlimit.html"><i>setrlimit</i>()</a> functions,
     96 defined in the System Interfaces volume of POSIX.1-2024, the option corresponds to.</p>
     97 <p>If neither the <b>-H</b> nor <b>-S</b> option is specified:</p>
     98 <ul>
     99 <li>
    100 <p>If the <i>newlimit</i> operand is present, it shall be used as the new value for both the hard and soft limits.</p>
    101 </li>
    102 <li>
    103 <p>If the <i>newlimit</i> operand is not present, <b>-S</b> shall be the default.</p>
    104 </li>
    105 </ul>
    106 <p>If no options other than <b>-H</b> or <b>-S</b> are specified, the behavior shall be as if the <b>-f</b> option was (also)
    107 specified.</p>
    108 <p>If any option other than <b>-H</b> or <b>-S</b> is repeated, the behavior is unspecified.</p>
    109 </blockquote>
    110 <h4 class="mansect"><a name="tag_20_131_05" id="tag_20_131_05"></a>OPERANDS</h4>
    111 <blockquote>
    112 <p>The following operand shall be supported:</p>
    113 <dl compact>
    114 <dd></dd>
    115 <dt><i>newlimit</i></dt>
    116 <dd>Either an integer value to use as the new limit(s) for the specified resource, in the units specified in OPTIONS, or a
    117 non-numeric string indicating no limit, as described in the DESCRIPTION section. Numerals in the range 0 to the maximum limit value
    118 supported by the implementation for any resource shall be syntactically recognized as numeric values.</dd>
    119 </dl>
    120 </blockquote>
    121 <h4 class="mansect"><a name="tag_20_131_06" id="tag_20_131_06"></a>STDIN</h4>
    122 <blockquote>
    123 <p>Not used.</p>
    124 </blockquote>
    125 <h4 class="mansect"><a name="tag_20_131_07" id="tag_20_131_07"></a>INPUT FILES</h4>
    126 <blockquote>
    127 <p>None.</p>
    128 </blockquote>
    129 <h4 class="mansect"><a name="tag_20_131_08" id="tag_20_131_08"></a>ENVIRONMENT VARIABLES</h4>
    130 <blockquote>
    131 <p>The following environment variables shall affect the execution of <i>ulimit</i>:</p>
    132 <dl compact>
    133 <dd></dd>
    134 <dt><i>LANG</i></dt>
    135 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    136 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    137 variables used to determine the values of locale categories.)</dd>
    138 <dt><i>LC_ALL</i></dt>
    139 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    140 <dt><i>LC_CTYPE</i></dt>
    141 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    142 opposed to multi-byte characters in arguments).</dd>
    143 <dt><i>LC_MESSAGES</i></dt>
    144 <dd><br>
    145 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    146 <dt><i>NLSPATH</i></dt>
    147 <dd>Determine the location of messages objects and message catalogs.</dd>
    148 </dl>
    149 </blockquote>
    150 <h4 class="mansect"><a name="tag_20_131_09" id="tag_20_131_09"></a>ASYNCHRONOUS EVENTS</h4>
    151 <blockquote>
    152 <p>Default.</p>
    153 </blockquote>
    154 <h4 class="mansect"><a name="tag_20_131_10" id="tag_20_131_10"></a>STDOUT</h4>
    155 <blockquote>
    156 <p>The standard output shall be used when no <i>newlimit</i> operand is present.</p>
    157 <p>If the <b>-a</b> option is specified, the output written for each resource shall consist of one line that includes:</p>
    158 <ul>
    159 <li>
    160 <p>A short phrase identifying the resource (for example &quot;file size&quot;).</p>
    161 </li>
    162 <li>
    163 <p>An indication of the units used for the resource, if the corresponding option description in OPTIONS specifies the units to be
    164 used.</p>
    165 </li>
    166 <li>
    167 <p>The <i>ulimit</i> option used to specify the resource.</p>
    168 </li>
    169 <li>
    170 <p>The limit value.</p>
    171 </li>
    172 </ul>
    173 <p>The format used within each line is unspecified, except that the format used for the limit value shall be as described below for
    174 the case where a single limit value is written.</p>
    175 <p>If a single limit value is to be written; that is, the <b>-a</b> option is not specified and at most one option other than
    176 <b>-H</b> or <b>-S</b> is specified:</p>
    177 <ul>
    178 <li>
    179 <p>If the resource being reported has a numeric limit, the limit value shall be written in the following format:</p>
    180 <pre>
    181 <tt>"%1d\n", &lt;</tt><i>limit value</i><tt>&gt;
    182 </tt></pre>
    183 <p>where &lt;<i>limit value</i>&gt; is the value of the limit in the units specified in OPTIONS.</p>
    184 </li>
    185 <li>
    186 <p>If the resource being reported does not have a numeric limit, in the POSIX locale the following format shall be used:</p>
    187 <pre>
    188 <tt>"unlimited\n"
    189 </tt></pre></li>
    190 </ul>
    191 </blockquote>
    192 <h4 class="mansect"><a name="tag_20_131_11" id="tag_20_131_11"></a>STDERR</h4>
    193 <blockquote>
    194 <p>The standard error shall be used only for diagnostic messages.</p>
    195 </blockquote>
    196 <h4 class="mansect"><a name="tag_20_131_12" id="tag_20_131_12"></a>OUTPUT FILES</h4>
    197 <blockquote>
    198 <p>None.</p>
    199 </blockquote>
    200 <h4 class="mansect"><a name="tag_20_131_13" id="tag_20_131_13"></a>EXTENDED DESCRIPTION</h4>
    201 <blockquote>
    202 <p>None.</p>
    203 </blockquote>
    204 <h4 class="mansect"><a name="tag_20_131_14" id="tag_20_131_14"></a>EXIT STATUS</h4>
    205 <blockquote>
    206 <p>The following exit values shall be returned:</p>
    207 <dl compact>
    208 <dd></dd>
    209 <dt>&nbsp;0</dt>
    210 <dd>Successful completion.</dd>
    211 <dt>&gt;0</dt>
    212 <dd>A request for a higher limit was rejected or an error occurred.</dd>
    213 </dl>
    214 </blockquote>
    215 <h4 class="mansect"><a name="tag_20_131_15" id="tag_20_131_15"></a>CONSEQUENCES OF ERRORS</h4>
    216 <blockquote>
    217 <p>Default.</p>
    218 </blockquote>
    219 <hr>
    220 <div class="box"><em>The following sections are informative.</em></div>
    221 <h4 class="mansect"><a name="tag_20_131_16" id="tag_20_131_16"></a>APPLICATION USAGE</h4>
    222 <blockquote>
    223 <p>This utility is required to be intrinsic. See <a href="../utilities/V3_chap01.html#tag_18_07"><i>1.7 Intrinsic Utilities</i></a>
    224 for details.</p>
    225 <p>Since <i>ulimit</i> affects the current shell execution environment, it is always provided as a shell regular built-in. If it is
    226 called with an operand in a separate utility execution environment, such as one of the following:</p>
    227 <pre>
    228 <tt>nohup ulimit -f 10000
    229 env ulimit -S -c 10000
    230 </tt></pre>
    231 <p>it does not affect the limit(s) in the caller's environment.</p>
    232 <p>See also the APPLICATION USAGE for <a href="../functions/getrlimit.html#"><i>getrlimit</i></a> .</p>
    233 </blockquote>
    234 <h4 class="mansect"><a name="tag_20_131_17" id="tag_20_131_17"></a>EXAMPLES</h4>
    235 <blockquote>
    236 <p>Set the hard and soft file size limits to 51200 bytes:</p>
    237 <pre>
    238 <tt>ulimit -f 100
    239 </tt></pre>
    240 <p>Save and restore a soft resource limit (where <i>X</i> is an option letter specifying a resource):</p>
    241 <pre>
    242 <tt>saved=$(ulimit -</tt><i>X</i><tt>)
    243 
    244 ...
    245 
    246 ulimit -</tt><i>X</i><tt> -S "$saved"
    247 </tt></pre>
    248 <p>Execute a utility with a CPU limit of 5 minutes (using an asynchronous subshell to ensure the limit is set in a child
    249 process):</p>
    250 <pre>
    251 <tt>(ulimit -t 300; exec utility_name &lt;/dev/null) &
    252 wait $!
    253 </tt></pre></blockquote>
    254 <h4 class="mansect"><a name="tag_20_131_18" id="tag_20_131_18"></a>RATIONALE</h4>
    255 <blockquote>
    256 <p>The <i>ulimit</i> utility has no equivalent of the special values RLIM_SAVED_MAX and RLIM_SAVED_CUR returned by <a href=
    257 "../functions/getrlimit.html"><i>getrlimit</i>()</a>, as <i>ulimit</i> is required to be able to output, and accept as input, all
    258 numeric limit values supported by the system.</p>
    259 <p>Implementations differ in their behavior when the <b>-a</b> option is not specified and more than one option other than
    260 <b>-H</b> or <b>-S</b> is specified. Some write output for all of the specified resources in the same format as for <b>-a</b>;
    261 others write only the value for the last specified option. Both behaviors are allowed by the standard, since the SYNOPSIS lists the
    262 options as mutually exclusive.</p>
    263 </blockquote>
    264 <h4 class="mansect"><a name="tag_20_131_19" id="tag_20_131_19"></a>FUTURE DIRECTIONS</h4>
    265 <blockquote>
    266 <p>None.</p>
    267 </blockquote>
    268 <h4 class="mansect"><a name="tag_20_131_20" id="tag_20_131_20"></a>SEE ALSO</h4>
    269 <blockquote>
    270 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    271 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    272 <p>XSH <a href="../functions/getrlimit.html#"><i>getrlimit</i></a></p>
    273 </blockquote>
    274 <h4 class="mansect"><a name="tag_20_131_21" id="tag_20_131_21"></a>CHANGE HISTORY</h4>
    275 <blockquote>
    276 <p>First released in Issue 2.</p>
    277 </blockquote>
    278 <h4 class="mansect"><a name="tag_20_131_22" id="tag_20_131_22"></a>Issue 7</h4>
    279 <blockquote>
    280 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    281 </blockquote>
    282 <h4 class="mansect"><a name="tag_20_131_23" id="tag_20_131_23"></a>Issue 8</h4>
    283 <blockquote>
    284 <p>Austin Group Defect 854 is applied, adding a note to the APPLICATION USAGE section that this utility is required to be
    285 intrinsic.</p>
    286 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    287 <p>Austin Group Defect 1418 is applied, adding the <b>-H</b>, <b>-S</b>, <b>-a</b>, <b>-c</b>, <b>-d</b>, <b>-n</b>, <b>-s</b>,
    288 <b>-t</b>, and <b>-v</b> options, and relating the <b>-f</b> option to the RLIMIT_FSIZE resource for <a href=
    289 "../functions/setrlimit.html"><i>setrlimit</i>()</a>.</p>
    290 <p>Austin Group Defect 1669 is applied, moving the <i>ulimit</i> utility, excluding the <b>-t</b> option, from the XSI option to
    291 the Base.</p>
    292 </blockquote>
    293 <div class="box"><em>End of informative text.</em></div>
    294 <hr>
    295 <p>&nbsp;</p>
    296 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    297 <hr size="2" noshade>
    298 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    299 POSIX™ is a Trademark of The IEEE.<br>
    300 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    301 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    302 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    303 ]</font></center>
    304 <hr size="2" noshade>
    305 <div class="NAVHEADER">
    306 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    307 <tr class="nav">
    308 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/type.html" accesskey="P">&lt;&lt;&lt;
    309 Previous</a></td>
    310 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    311 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/umask.html" accesskey="N">Next
    312 &gt;&gt;&gt;</a></td>
    313 </tr>
    314 </table>
    315 <hr align="left" width="100%"></div>
    316 </body>
    317 </html>