<!DOCTYPE html PUBLIC "‐//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">     <html
xmlns="http://www.w3.org/1999/xhtml"> <head>
    <link            rel="stylesheet"             type="text/css"
href="../../../style.css" title="style" />
    <link  rel="stylesheet"  type="text/css"  href="../style.css"
title="style" />
    <meta             http‐equiv="content‐type"              con‐
tent="text/html;charset=utf‐8" />

    <title>fcntl.h.0p ‐ Linux manual page</title> </head>

<body>

<div        class="page‐top"><a       id="top_of_page"></a></div>
<!‐‐%%%TOP_BAR%%%‐‐> <!‐‐%%%PAGE_START%%%‐‐>

<table class="sec‐table"> <tr>
    <td>
        <p class="section‐dir"> <a href="#PROLOG">PROLOG</a> | <a
href="#NAME">NAME</a>  |  <a  href="#SYNOPSIS">SYNOPSIS</a>  | <a
href="#DESCRIPTION">DESCRIPTION</a> |  <a  href="#APPLICATION_US‐
AGE">APPLICATION&nbsp;USAGE</a>   |  <a  href="#RATIONALE">RATIO‐
NALE</a>   |   <a    href="#FUTURE_DIRECTIONS">FUTURE&nbsp;DIREC‐
TIONS</a>    |   <a   href="#SEE_ALSO">SEE&nbsp;ALSO</a>   |   <a
href="#COPYRIGHT">COPYRIGHT</a>
        </p>
    </td>
    <td class="search‐box">
        <div class="man‐search‐box">

            <form                method="get"                 ac‐
tion="http://www.google.com/search">
                <fieldset class="man‐search">
                    <input    type="text"    name="q"   size="10"
maxlength="255" value="" />
                    <input type="hidden"  name="sitesearch"  val‐
ue="man7.org/linux/man‐pages" />
                    <input  type="submit" name="sa" value="Search
online pages" />
                </fieldset>
            </form>

        </div>
    </td>
    <td> </td> </tr> </table>

<pre> <span class="headline">fcntl.h(0P)               POSIX Pro‐
grammer’s  Manual               fcntl.h(0P)</span>  </pre> <h2><a
id="PROLOG" href="#PROLOG"></a>PROLOG  &nbsp; &nbsp; &nbsp;  &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       This manual page is part of the POSIX Programmer’s Manual.
The Linux
       implementation of this interface may differ (consult the
       corresponding  Linux  manual page for details of Linux be‐
havior), or
       the interface may not be  implemented  on  Linux.   </pre>
<h2><a id="NAME" href="#NAME"></a>NAME  &nbsp; &nbsp; &nbsp; &nb‐
sp;        <a        href="#top_of_page"><span        class="top‐
link">top</span></a></h2><pre>
       fcntl.h — file control options </pre> <h2><a id="SYNOPSIS"
href="#SYNOPSIS"></a>SYNOPSIS  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       #include &lt;fcntl.h&gt;  </pre>  <h2><a  id="DESCRIPTION"
href="#DESCRIPTION"></a>DESCRIPTION   &nbsp; &nbsp; &nbsp; &nbsp;
<a             href="#top_of_page"><span              class="top‐
link">top</span></a></h2><pre>
       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constants
       for the <i>cmd</i> argument used by  <i>fcntl</i>().   The
values shall be unique and
       shall  be suitable for use in <b>#if </b>preprocessing di‐
rectives.

       F_DUPFD     Duplicate file descriptor.

       F_DUPFD_CLOEXEC
                   Duplicate  file  descriptor  with  the  close‐
on‐<i>exec</i> flag
                   FD_CLOEXEC set.

       F_GETFD     Get file descriptor flags.

       F_SETFD     Set file descriptor flags.

       F_GETFL     Get file status flags and file access modes.

       F_SETFL     Set file status flags.

       F_GETLK     Get record locking information.

       F_SETLK     Set record locking information.

       F_SETLKW      Set  record  locking  information;  wait  if
blocked.

       F_GETOWN    Get process or process  group  ID  to  receive
SIGURG
                   signals.

       F_SETOWN     Set  process  or  process group ID to receive
SIGURG
                   signals.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant
       used  for  the <i>fcntl</i>() file descriptor flags, which
shall be suitable
       for use in <b>#if </b>preprocessing directives.

       FD_CLOEXEC  Close the file descriptor upon execution of an
<i>exec</i>
                   family function.

       The  <i>&lt;fcntl.h&gt;</i>  header  shall also define the
following symbolic
       constants for the <i>l_type</i> argument used  for  record
locking with
       <i>fcntl</i>().   The  values shall be unique and shall be
suitable for use in
       <b>#if </b>preprocessing directives.

       F_RDLCK     Shared or read lock.

       F_UNLCK     Unlock.

       F_WRLCK     Exclusive or write lock.

       The <i>&lt;fcntl.h&gt;</i> header shall define the  values
used for <i>l_whence</i>,
       SEEK_SET,   SEEK_CUR,   and   SEEK_END   as  described  in
<i>&lt;stdio.h&gt;</i>.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constants as
       file  creation  flags for use in the <i>oflag</i> value to
<i>open</i>() and
       <i>openat</i>().  The values shall be bitwise‐distinct and
shall be suitable
       for use in <b>#if </b>preprocessing directives.

       O_CLOEXEC    The  FD_CLOEXEC  flag associated with the new
descriptor
                   shall be set to close the file descriptor upon
execution
                   of an <i>exec</i> family function.

       O_CREAT     Create file if it does not exist.

       O_DIRECTORY Fail if not a directory.

       O_EXCL      Exclusive use flag.

       O_NOCTTY    Do not assign controlling terminal.

       O_NOFOLLOW  Do not follow symbolic links.

       O_TRUNC     Truncate flag.

       O_TTY_INIT   Set the <b>termios </b>structure terminal pa‐
rameters to a state
                   that provides conforming behavior; see <i>Sec‐
tion 11.2</i>,
                   <i>Parameters that Can be Set</i>.

       The  O_TTY_INIT  flag  can have the value zero and in this
case it need
       not be bitwise‐distinct from the other flags.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constants
       for  use  as  file status flags for <i>open</i>(), <i>ope‐
nat</i>(), and <i>fcntl</i>().  The
       values shall be suitable for use in <b>#if </b>preprocess‐
ing directives.

       O_APPEND    Set append mode.

       O_DSYNC      Write  according to synchronized I/O data in‐
tegrity
                   completion.

       O_NONBLOCK  Non‐blocking mode.

       O_RSYNC     Synchronized read I/O operations.

       O_SYNC      Write according to synchronized I/O  file  in‐
tegrity
                   completion.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant for
       use as the mask for file access modes. The value shall  be
suitable
       for use in <b>#if </b>preprocessing directives.

       O_ACCMODE   Mask for file access modes.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constants
       for use  as  the  file  access  modes  for  <i>open</i>(),
<i>openat</i>(), and <i>fcntl</i>().
       The  values  shall  be  unique,  except  that  O_EXEC  and
O_SEARCH may have
       equal values. The values shall  be  suitable  for  use  in
<b>#if</b>
       preprocessing directives.

       O_EXEC       Open  for execute only (non‐directory files).
The result
                   is unspecified if this flag is  applied  to  a
directory.

       O_RDONLY    Open for reading only.

       O_RDWR      Open for reading and writing.

       O_SEARCH     Open directory for search only. The result is
unspecified
                   if this flag is  applied  to  a  non‐directory
file.

       O_WRONLY    Open for writing only.

       The <i>&lt;fcntl.h&gt;</i> header shall define the symbol‐
ic constants for file
       modes for use as values of <b>mode_t </b>as  described  in
<i>&lt;sys/stat.h&gt;</i>.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant as
       a special value used in place of a file descriptor for the
<i>*at</i>()
       functions  which take a directory file descriptor as a pa‐
rameter:

       AT_FDCWD    Use the current working directory to determine
the target
                   of relative file paths.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant as
       a value for the <i>flag</i> used by <i>faccessat</i>():

       AT_EACCESS  Check access using effective  user  and  group
ID.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant as
       a value for  the  <i>flag</i>  used  by  <i>fstatat</i>(),
<i>fchmodat</i>(), <i>fchownat</i>(), and
       <i>utimensat</i>():

       AT_SYMLINK_NOFOLLOW
                   Do not follow symbolic links.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant as
       a value for the flag used by <i>linkat</i>():

       AT_SYMLINK_FOLLOW
                   Follow symbolic link.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constant as
       a value for the flag used by <i>unlinkat</i>():

       AT_REMOVEDIR
                   Remove directory instead of file.

       The <i>&lt;fcntl.h&gt;</i> header shall define the follow‐
ing symbolic constants
       for  the  <i>advice</i>  argument  used  by  <i>posix_fad‐
vise</i>():

       POSIX_FADV_DONTNEED
             The  application expects that it will not access the
specified
             data in the near future.

       POSIX_FADV_NOREUSE
             The application expects to access the specified data
once and
             then not reuse it thereafter.

       POSIX_FADV_NORMAL
             The  application has no advice to give on its behav‐
ior with
             respect to the specified data.  It  is  the  default
characteristic
             if no advice is given for an open file.

       POSIX_FADV_RANDOM
             The application expects to access the specified data
in a
             random order.

       POSIX_FADV_SEQUENTIAL
             The application expects to access the specified data
             sequentially from lower offsets to higher offsets.

       POSIX_FADV_WILLNEED
             The application expects to access the specified data
in the
             near future.

       The   <i>&lt;fcntl.h&gt;</i>   header   shall  define  the
<b>flock </b>structure describing a
       file lock. It shall include the following members:

           <b>short  l_type   </b>Type of lock; F_RDLCK, F_WRLCK,
F_UNLCK.
           short  l_whence Flag for starting offset.
           off_t  l_start  Relative offset in bytes.
           off_t  l_len    Size; if 0 then until EOF.
           pid_t   l_pid    Process ID of the process holding the
lock; returned with F_GETLK.

       The  <i>&lt;fcntl.h&gt;</i>  header   shall   define   the
<b>mode_t</b>, <b>off_t</b>, and <b>pid_t </b>types
       as described in <i>&lt;sys/types.h&gt;</i>.

       The  following shall be declared as functions and may also
be defined
       as macros. Function prototypes shall be provided.

           <b>int  creat(const char *, mode_t);</b>
           <b>int  fcntl(int, int, ...);</b>
           <b>int  open(const char *, int, ...);</b>
           <b>int  openat(int, const char *, int, ...);</b>
           <b>int  posix_fadvise(int, off_t, off_t, int);</b>
           <b>int  posix_fallocate(int, off_t, off_t);</b>

       Inclusion of the <i>&lt;fcntl.h&gt;</i>  header  may  also
make visible all symbols
       from             <i>&lt;sys/stat.h&gt;</i>             and
<i>&lt;unistd.h&gt;</i>.

       <i>The  following  sections  are  informative.</i>  </pre>
<h2><a  id="APPLICATION_USAGE"  href="#APPLICATION_USAGE"></a>AP‐
PLICATION    USAGE     &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       Although  no  existing  implementation   defines   AT_SYM‐
LINK_FOLLOW and
       AT_SYMLINK_NOFOLLOW    as    the   same   numeric   value,
POSIX.1‐2008 does not
       prohibit that as the two constants are not used  with  the
same
       interfaces.   </pre>  <h2><a  id="RATIONALE" href="#RATIO‐
NALE"></a>RATIONALE    &nbsp;    &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       While many of the symbolic  constants  introduced  in  the
<i>&lt;fcntl.h&gt;</i>
       header  do not strictly need to be used in <b>#if </b>pre‐
processor
       directives, widespread historic practice has defined  them
as macros
       that are usable in such constructs, and examination of ex‐
isting
       applications has shown that they are occasionally used  in
such a way.
       Therefore it was decided to retain this requirement on an
       implementation  in  POSIX.1‐2008.   </pre>  <h2><a id="FU‐
TURE_DIRECTIONS" href="#FUTURE_DIRECTIONS"></a>FUTURE  DIRECTIONS
&nbsp;   &nbsp;   &nbsp;   &nbsp;   <a  href="#top_of_page"><span
class="top‐link">top</span></a></h2><pre>
       None.    </pre>   <h2><a   id="SEE_ALSO"    href="#SEE_AL‐
SO"></a>SEE    ALSO     &nbsp;    &nbsp;    &nbsp;    &nbsp;   <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       <a    href="../man0/stdio.h.0p.html">stdio.h(0p)</a>,   <a
href="../man0/sys_stat.h.0p.html">sys_stat.h(0p)</a>,          <a
href="../man0/sys_types.h.0p.html">sys_types.h(0p)</a>,        <a
href="../man0/unistd.h.0p.html">unistd.h(0p)</a>

       The  System  Interfaces   volume   of   POSIX.1‐2008,   <a
href="../man3/creat.3p.html">creat(3p)</a>,  <a href="../man1/ex‐
ec.1p.html">exec(1p)</a>,
       <a     href="../man3/fcntl.3p.html">fcntl(3p)</a>,      <a
href="../man3/futimens.3p.html">futimens(3p)</a>,              <a
href="../man3/open.3p.html">open(3p)</a>,                      <a
href="../man3/posix_fadvise.3p.html">posix_fadvise(3p)</a>,
       <a     href="../man3/posix_fallocate.3p.html">posix_fallo‐
cate(3p)</a>, <a  href="../man3/posix_madvise.3p.html">posix_mad‐
vise(3p)</a>    </pre>    <h2><a    id="COPYRIGHT"   href="#COPY‐
RIGHT"></a>COPYRIGHT    &nbsp;   &nbsp;    &nbsp;    &nbsp;    <a
href="#top_of_page"><span                             class="top‐
link">top</span></a></h2><pre>
       Portions of this text  are  reprinted  and  reproduced  in
electronic form
       from  IEEE Std 1003.1, 2013 Edition, Standard for Informa‐
tion
       Technology ‐‐ Portable Operating System Interface (POSIX),
The Open
       Group  Base  Specifications Issue 7, Copyright (C) 2013 by
the
       Institute of Electrical and Electronics Engineers, Inc and
The Open
       Group.  (This is POSIX.1‐2008 with the 2013 Technical Cor‐
rigendum 1
       applied.) In the event of  any  discrepancy  between  this
version and
       the  original IEEE and The Open Group Standard, the origi‐
nal IEEE and
       The Open Group Standard is the referee document. The orig‐
inal
       Standard     can     be     obtained    online    at    <a
href="http://www.unix.org/online.html">http://www.unix.org/on‐
line.html</a> .

       Any typographical or formatting errors that appear in this
page are
       most likely to have been introduced during the  conversion
of the
       source  files  to  man page format. To report such errors,
see
       <a      href="https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html">https://www.kernel.org/doc/man‐pages/report‐
ing_bugs.html</a> .

<span class="footline">IEEE/The Open  Group                  2013
fcntl.h(0P)</span> </pre>

<hr class="end‐man‐text" />

<hr class="start‐footer" />

<div class="footer">

<table class="colophon‐table">
    <tr>
    <td class="pub‐info">
        <p>
            HTML rendering created 2019‐08‐02
            by  <a  href="http://man7.org/mtk/index.html">Michael
Kerrisk</a>,
            author of
            <a  href="http://man7.org/tlpi/"><em>The  Linux  Pro‐
gramming Interface</em></a>,
            maintainer of the
            <a href="https://www.kernel.org/doc/man‐pages/">Linux
<em>man‐pages</em> project</a>.
        </p>
        <p>
            For details of in‐depth
            <strong>Linux/UNIX system programming training  cour‐
ses</strong>
            that  I  teach,  look <a href="http://man7.org/train‐
ing/">here</a>.
        </p>
        <p>
            Hosting   by    <a    href="http://www.jambit.com/in‐
dex_en.html">jambit GmbH</a>.
        </p>
        <p>
            <a href="http://validator.w3.org/check?uri=referer">
            <img src="http://www.w3.org/Icons/valid‐xhtml11"
                alt="Valid XHTML 1.1" height="31" width="88" />
            </a>
        </p>
    </td>
    <td class="colophon‐divider">
    </td>
    <td class="tlpi‐cover">
        <a                      href="http://man7.org/tlpi/"><img
src="http://man7.org/tlpi/cover/TLPI‐front‐cover‐vsmall.png"
alt="Cover of TLPI" /></a>
    </td>
    </tr> </table>

</div>

<hr class="end‐footer" />

</body> </html>