fcntl.h(3)                 POSIX Programmer's Manual                fcntl.h(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       fcntl.h -- file control options

SSYYNNOOPPSSIISS
       #include <fcntl.h>

DDEESSCCRRIIPPTTIIOONN
       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constants for
       the _c_m_d argument used by _f_c_n_t_l().  The values shall be unique and shall
       be suitable for use in ##iiff preprocessing directives.

       F_DUPFD     Duplicate file descriptor.

       F_DUPFD_CLOEXEC
                   Duplicate file descriptor with the close-on-_e_x_e_c 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 _<_f_c_n_t_l_._h_> header shall define the following symbolic constant used
       for the _f_c_n_t_l() file descriptor flags, which shall be suitable for use
       in ##iiff preprocessing directives.

       FD_CLOEXEC  Close the file descriptor upon execution of an _e_x_e_c family
                   function.

       The _<_f_c_n_t_l_._h_> header shall also define the following symbolic constants
       for the _l___t_y_p_e argument used for record locking with _f_c_n_t_l().  The
       values shall be unique and shall be suitable for use in ##iiff
       preprocessing directives.

       F_RDLCK     Shared or read lock.

       F_UNLCK     Unlock.

       F_WRLCK     Exclusive or write lock.

       The _<_f_c_n_t_l_._h_> header shall define the values used for _l___w_h_e_n_c_e,
       SEEK_SET, SEEK_CUR, and SEEK_END as described in _<_s_t_d_i_o_._h_>.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constants as
       file creation flags for use in the _o_f_l_a_g value to _o_p_e_n() and _o_p_e_n_a_t().
       The values shall be bitwise-distinct and shall be suitable for use in
       ##iiff 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 _e_x_e_c 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 tteerrmmiiooss structure terminal parameters to a state
                   that provides conforming behavior; see _S_e_c_t_i_o_n _1_1_._2,
                   _P_a_r_a_m_e_t_e_r_s _t_h_a_t _C_a_n _b_e _S_e_t.

       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 _<_f_c_n_t_l_._h_> header shall define the following symbolic constants for
       use as file status flags for _o_p_e_n(), _o_p_e_n_a_t(), and _f_c_n_t_l().  The values
       shall be suitable for use in ##iiff preprocessing directives.

       O_APPEND    Set append mode.

       O_DSYNC     Write according to synchronized I/O data integrity
                   completion.

       O_NONBLOCK  Non-blocking mode.

       O_RSYNC     Synchronized read I/O operations.

       O_SYNC      Write according to synchronized I/O file integrity
                   completion.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant for
       use as the mask for file access modes. The value shall be suitable for
       use in ##iiff preprocessing directives.

       O_ACCMODE   Mask for file access modes.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constants for
       use as the file access modes for _o_p_e_n(), _o_p_e_n_a_t(), and _f_c_n_t_l().  The
       values shall be unique, except that O_EXEC and O_SEARCH may have equal
       values. The values shall be suitable for use in ##iiff 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 _<_f_c_n_t_l_._h_> header shall define the symbolic constants for file modes
       for use as values of mmooddee__tt as described in _<_s_y_s_/_s_t_a_t_._h_>.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant as a
       special value used in place of a file descriptor for the _*_a_t()
       functions which take a directory file descriptor as a parameter:

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

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant as a
       value for the _f_l_a_g used by _f_a_c_c_e_s_s_a_t():

       AT_EACCESS  Check access using effective user and group ID.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant as a
       value for the _f_l_a_g used by _f_s_t_a_t_a_t(), _f_c_h_m_o_d_a_t(), _f_c_h_o_w_n_a_t(), and
       _u_t_i_m_e_n_s_a_t():

       AT_SYMLINK_NOFOLLOW
                   Do not follow symbolic links.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant as a
       value for the flag used by _l_i_n_k_a_t():

       AT_SYMLINK_FOLLOW
                   Follow symbolic link.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constant as a
       value for the flag used by _u_n_l_i_n_k_a_t():

       AT_REMOVEDIR
                   Remove directory instead of file.

       The _<_f_c_n_t_l_._h_> header shall define the following symbolic constants for
       the _a_d_v_i_c_e argument used by _p_o_s_i_x___f_a_d_v_i_s_e():

       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 behavior 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 _<_f_c_n_t_l_._h_> header shall define the fflloocckk structure describing a file
       lock. It shall include the following members:

           sshhoorrtt  ll__ttyyppee   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 _<_f_c_n_t_l_._h_> header shall define the mmooddee__tt, ooffff__tt, and ppiidd__tt types as
       described in _<_s_y_s_/_t_y_p_e_s_._h_>.

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

           iinntt  ccrreeaatt((ccoonnsstt cchhaarr **,, mmooddee__tt));;
           iinntt  ffccnnttll((iinntt,, iinntt,, ......));;
           iinntt  ooppeenn((ccoonnsstt cchhaarr **,, iinntt,, ......));;
           iinntt  ooppeennaatt((iinntt,, ccoonnsstt cchhaarr **,, iinntt,, ......));;
           iinntt  ppoossiixx__ffaaddvviissee((iinntt,, ooffff__tt,, ooffff__tt,, iinntt));;
           iinntt  ppoossiixx__ffaallllooccaattee((iinntt,, ooffff__tt,, ooffff__tt));;

       Inclusion of the _<_f_c_n_t_l_._h_> header may also make visible all symbols
       from _<_s_y_s_/_s_t_a_t_._h_> and _<_u_n_i_s_t_d_._h_>.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       Although no existing implementation defines AT_SYMLINK_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.

RRAATTIIOONNAALLEE
       While many of the symbolic constants introduced in the _<_f_c_n_t_l_._h_> header
       do not strictly need to be used in ##iiff preprocessor directives,
       widespread historic practice has defined them as macros that are usable
       in such constructs, and examination of existing 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.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       <<ssttddiioo..hh>>, <<ssyyss__ssttaatt..hh>>, <<ssyyss__ttyyppeess..hh>>, <<uunniissttdd..hh>>

       The System Interfaces volume of POSIX.1-2008, _c_r_e_a_t(), _e_x_e_c, _f_c_n_t_l(),
       _f_u_t_i_m_e_n_s(), _o_p_e_n(), _p_o_s_i_x___f_a_d_v_i_s_e(), _p_o_s_i_x___f_a_l_l_o_c_a_t_e(), _p_o_s_i_x___m_a_d_v_i_s_e()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information 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 Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       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
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                           fcntl.h(3)
