<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>MLtonRlimit</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>MLtonRlimit</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="k">signature</span><span class="w"> </span><span class="n">MLTON_RLIMIT</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">sig</span><span class="w"></span>
<span class="w">      </span><span class="k">structure</span><span class="w"> </span><span class="n">RLim</span><span class="w"> </span><span class="p">:</span><span class="w"> </span><span class="k">sig</span><span class="w"></span>
<span class="w">                          </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"></span>
<span class="w">                          </span><span class="k">val</span><span class="w"> </span><span class="n">castFromSysWord</span><span class="p">:</span><span class="w"> </span><span class="n">SysWord</span><span class="p">.</span><span class="n">word</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">t</span><span class="w"></span>
<span class="w">                          </span><span class="k">val</span><span class="w"> </span><span class="n">castToSysWord</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">SysWord</span><span class="p">.</span><span class="n">word</span><span class="w"></span>
<span class="w">                       </span><span class="k">end</span><span class="w"></span>

<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">infinity</span><span class="p">:</span><span class="w"> </span><span class="n">RLim</span><span class="p">.</span><span class="n">t</span><span class="w"></span>

<span class="w">      </span><span class="k">type</span><span class="w"> </span><span class="n">t</span><span class="w"></span>

<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">coreFileSize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">        </span><span class="cm">(* CORE    max core file size *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">cpuTime</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">             </span><span class="cm">(* CPU     CPU time in seconds *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">dataSize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">            </span><span class="cm">(* DATA    max data size *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">fileSize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">            </span><span class="cm">(* FSIZE   Maximum filesize *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">numFiles</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">            </span><span class="cm">(* NOFILE  max number of open files *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">lockedInMemorySize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">  </span><span class="cm">(* MEMLOCK max locked address space *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">numProcesses</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">        </span><span class="cm">(* NPROC   max number of processes *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">residentSetSize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">     </span><span class="cm">(* RSS     max resident set size *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">stackSize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">           </span><span class="cm">(* STACK   max stack size *)</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">virtualMemorySize</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w">   </span><span class="cm">(* AS      virtual memory limit *)</span><span class="w"></span>

<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">get</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="p">{</span><span class="n">hard</span><span class="p">:</span><span class="w"> </span><span class="n">rlim</span><span class="p">,</span><span class="w"> </span><span class="n">soft</span><span class="p">:</span><span class="w"> </span><span class="n">rlim</span><span class="p">}</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">set</span><span class="p">:</span><span class="w"> </span><span class="n">t</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="p">{</span><span class="n">hard</span><span class="p">:</span><span class="w"> </span><span class="n">rlim</span><span class="p">,</span><span class="w"> </span><span class="n">soft</span><span class="p">:</span><span class="w"> </span><span class="n">rlim</span><span class="p">}</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p><span class="monospaced">MLton.Rlimit</span> provides a wrapper around the C <span class="monospaced">getrlimit</span> and
<span class="monospaced">setrlimit</span> functions.</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">type Rlim.t</span>
</p>
<div class="paragraph"><p>the type of resource limits.</p></div>
</li>
<li>
<p>
<span class="monospaced">infinity</span>
</p>
<div class="paragraph"><p>indicates that a resource is unlimited.</p></div>
</li>
<li>
<p>
<span class="monospaced">type t</span>
</p>
<div class="paragraph"><p>the types of resources that can be inspected and modified.</p></div>
</li>
<li>
<p>
<span class="monospaced">get r</span>
</p>
<div class="paragraph"><p>returns the current hard and soft limits for resource <span class="monospaced">r</span>. May raise
<span class="monospaced">OS.SysErr</span>.</p></div>
</li>
<li>
<p>
<span class="monospaced">set (r, {hard, soft})</span>
</p>
<div class="paragraph"><p>sets the hard and soft limits for resource <span class="monospaced">r</span>.  May raise
<span class="monospaced">OS.SysErr</span>.</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
