HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/share/doc/ruby/html/Fcntl.html
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>module Fcntl - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
</script>

<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">




<body id="top" role="document" class="module">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="./index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    
    
    
    
  </div>
</nav>

<main role="main" aria-labelledby="module-Fcntl">
  <h1 id="module-Fcntl" class="module">
    module Fcntl
  </h1>

  <section class="description">
    
<p><a href="Fcntl.html"><code>Fcntl</code></a> loads the constants defined in the system&#39;s &lt;fcntl.h&gt; C header file, and used with both the fcntl(2) and open(2) POSIX system calls.</p>

<p>To perform a fcntl(2) operation, use IO::fcntl.</p>

<p>To perform an open(2) operation, use <a href="IO.html#method-c-sysopen"><code>IO::sysopen</code></a>.</p>

<p>The set of operations and constants available depends upon specific operating system.  Some values listed below may not be supported on your system.</p>

<p>See your fcntl(2) man page for complete details.</p>

<p>Open /tmp/tempfile as a write-only file that is created if it doesn&#39;t exist:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;fcntl&#39;</span>

<span class="ruby-identifier">fd</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">sysopen</span>(<span class="ruby-string">&#39;/tmp/tempfile&#39;</span>,
                <span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">O_WRONLY</span> <span class="ruby-operator">|</span> <span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">O_EXCL</span> <span class="ruby-operator">|</span> <span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">O_CREAT</span>)
<span class="ruby-identifier">f</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">fd</span>)
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">syswrite</span>(<span class="ruby-string">&quot;TEMP DATA&quot;</span>)
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">close</span>
</pre>

<p>Get the flags on file <code>s</code>:</p>

<pre class="ruby"><span class="ruby-identifier">m</span> = <span class="ruby-identifier">s</span>.<span class="ruby-identifier">fcntl</span>(<span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">F_GETFL</span>, <span class="ruby-value">0</span>)
</pre>

<p><a href="Set.html"><code>Set</code></a> the non-blocking flag on <code>f</code> in addition to the existing flags in <code>m</code>.</p>

<pre class="ruby"><span class="ruby-identifier">f</span>.<span class="ruby-identifier">fcntl</span>(<span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">F_SETFL</span>, <span class="ruby-constant">Fcntl</span><span class="ruby-operator">::</span><span class="ruby-constant">O_NONBLOCK</span><span class="ruby-operator">|</span><span class="ruby-identifier">m</span>)
</pre>

  </section>

  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    
    <section class="constants-list">
      <header>
        <h3>Constants</h3>
      </header>
      <dl>
      
        <dt id="FD_CLOEXEC">FD_CLOEXEC
        
        <dd><p><a href="Fcntl.html#FD_CLOEXEC"><code>FD_CLOEXEC</code></a></p>

<p>the value of the close-on-exec flag.</p>
        
      
        <dt id="F_DUPFD">F_DUPFD
        
        <dd><p><a href="Fcntl.html#F_DUPFD"><code>F_DUPFD</code></a></p>

<p>Duplicate a file descriptor to the minimum unused file descriptor greater than or equal to the argument.</p>

<p>The close-on-exec flag of the duplicated file descriptor is set. (Ruby uses F_DUPFD_CLOEXEC internally if available to avoid race condition.  <a href="Fcntl.html#F_SETFD"><code>F_SETFD</code></a> is used if F_DUPFD_CLOEXEC is not available.)</p>
        
      
        <dt id="F_GETFD">F_GETFD
        
        <dd><p><a href="Fcntl.html#F_GETFD"><code>F_GETFD</code></a></p>

<p>Read the close-on-exec flag of a file descriptor.</p>
        
      
        <dt id="F_GETFL">F_GETFL
        
        <dd><p><a href="Fcntl.html#F_GETFL"><code>F_GETFL</code></a></p>

<p>Get the file descriptor flags.  This will be one or more of the O_* flags.</p>
        
      
        <dt id="F_GETLK">F_GETLK
        
        <dd><p><a href="Fcntl.html#F_GETLK"><code>F_GETLK</code></a></p>

<p>Determine whether a given region of a file is locked.  This uses one of the F_*LK flags.</p>
        
      
        <dt id="F_RDLCK">F_RDLCK
        
        <dd><p><a href="Fcntl.html#F_RDLCK"><code>F_RDLCK</code></a></p>

<p>Read lock for a region of a file</p>
        
      
        <dt id="F_SETFD">F_SETFD
        
        <dd><p><a href="Fcntl.html#F_SETFD"><code>F_SETFD</code></a></p>

<p><a href="Set.html"><code>Set</code></a> the close-on-exec flag of a file descriptor.</p>
        
      
        <dt id="F_SETFL">F_SETFL
        
        <dd><p><a href="Fcntl.html#F_SETFL"><code>F_SETFL</code></a></p>

<p><a href="Set.html"><code>Set</code></a> the file descriptor flags.  This will be one or more of the O_* flags.</p>
        
      
        <dt id="F_SETLK">F_SETLK
        
        <dd><p><a href="Fcntl.html#F_SETLK"><code>F_SETLK</code></a></p>

<p>Acquire a lock on a region of a file.  This uses one of the F_*LCK flags.</p>
        
      
        <dt id="F_SETLKW">F_SETLKW
        
        <dd><p><a href="Fcntl.html#F_SETLKW"><code>F_SETLKW</code></a></p>

<p>Acquire a lock on a region of a file, waiting if necessary.  This uses one of the F_*LCK flags</p>
        
      
        <dt id="F_UNLCK">F_UNLCK
        
        <dd><p><a href="Fcntl.html#F_UNLCK"><code>F_UNLCK</code></a></p>

<p>Remove lock for a region of a file</p>
        
      
        <dt id="F_WRLCK">F_WRLCK
        
        <dd><p><a href="Fcntl.html#F_WRLCK"><code>F_WRLCK</code></a></p>

<p>Write lock for a region of a file</p>
        
      
        <dt id="O_ACCMODE">O_ACCMODE
        
        <dd><p><a href="Fcntl.html#O_ACCMODE"><code>O_ACCMODE</code></a></p>

<p>Mask to extract the read/write flags</p>
        
      
        <dt id="O_APPEND">O_APPEND
        
        <dd><p><a href="Fcntl.html#O_APPEND"><code>O_APPEND</code></a></p>

<p>Open the file in append mode</p>
        
      
        <dt id="O_CREAT">O_CREAT
        
        <dd><p><a href="Fcntl.html#O_CREAT"><code>O_CREAT</code></a></p>

<p>Create the file if it doesn&#39;t exist</p>
        
      
        <dt id="O_EXCL">O_EXCL
        
        <dd><p><a href="Fcntl.html#O_EXCL"><code>O_EXCL</code></a></p>

<p>Used with <a href="Fcntl.html#O_CREAT"><code>O_CREAT</code></a>, fail if the file exists</p>
        
      
        <dt id="O_NDELAY">O_NDELAY
        
        <dd><p><a href="Fcntl.html#O_NDELAY"><code>O_NDELAY</code></a></p>

<p>Open the file in non-blocking mode</p>
        
      
        <dt id="O_NOCTTY">O_NOCTTY
        
        <dd><p><a href="Fcntl.html#O_NOCTTY"><code>O_NOCTTY</code></a></p>

<p>Open TTY without it becoming the controlling TTY</p>
        
      
        <dt id="O_NONBLOCK">O_NONBLOCK
        
        <dd><p><a href="Fcntl.html#O_NONBLOCK"><code>O_NONBLOCK</code></a></p>

<p>Open the file in non-blocking mode</p>
        
      
        <dt id="O_RDONLY">O_RDONLY
        
        <dd><p><a href="Fcntl.html#O_RDONLY"><code>O_RDONLY</code></a></p>

<p>Open the file in read-only mode</p>
        
      
        <dt id="O_RDWR">O_RDWR
        
        <dd><p><a href="Fcntl.html#O_RDWR"><code>O_RDWR</code></a></p>

<p>Open the file in read-write mode</p>
        
      
        <dt id="O_TRUNC">O_TRUNC
        
        <dd><p><a href="Fcntl.html#O_TRUNC"><code>O_TRUNC</code></a></p>

<p>Truncate the file on open</p>
        
      
        <dt id="O_WRONLY">O_WRONLY
        
        <dd><p><a href="Fcntl.html#O_WRONLY"><code>O_WRONLY</code></a></p>

<p>Open the file in write-only mode.</p>
        
      
      </dl>
    </section>
    

    

    
  </section>

</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>