1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "<fcntl.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 fcntl.h \- file control options
8 \fB#include <fcntl.h>\fP
11 The \fI<fcntl.h>\fP header shall define the following requests and
12 arguments for use by the functions \fIfcntl\fP() and \fIopen\fP().
14 Values for \fIcmd\fP used by \fIfcntl\fP() (the following values are
19 Duplicate file descriptor.
22 Get file descriptor flags.
25 Set file descriptor flags.
28 Get file status flags and file access modes.
31 Set file status flags.
34 Get record locking information.
37 Set record locking information.
40 Set record locking information; wait if blocked.
43 Get process or process group ID to receive SIGURG signals.
46 Set process or process group ID to receive SIGURG signals.
49 File descriptor flags used for \fIfcntl\fP() are as follows:
52 Close the file descriptor upon execution of an \fIexec\fP family function.
55 Values for \fIl_type\fP used for record locking with \fIfcntl\fP()
57 are unique) are as follows:
66 Exclusive or write lock.
69 The values used for \fIl_whence\fP, SEEK_SET, SEEK_CUR, and SEEK_END
70 shall be defined as described in \fI<unistd.h>\fP .
72 The following values are file creation flags and are used in the \fIoflag\fP
73 value to \fIopen\fP(). They shall be bitwise-distinct.
76 Create file if it does not exist.
82 Do not assign controlling terminal.
88 File status flags used for \fIopen\fP() and \fIfcntl\fP() are as follows:
94 Write according to synchronized I/O data integrity completion.
100 Synchronized read I/O operations.
103 Write according to synchronized I/O file integrity completion.
106 Mask for use with file access modes is as follows:
109 Mask for file access modes.
112 File access modes used for \fIopen\fP() and \fIfcntl\fP() are as follows:
115 Open for reading only.
118 Open for reading and writing.
121 Open for writing only.
124 The symbolic names for file modes for use as values of \fBmode_t\fP
125 shall be defined as described in \fI<sys/stat.h>\fP .
127 Values for \fIadvice\fP used by \fIposix_fadvise\fP() are as follows:
131 The application has no advice to give on its behavior with respect
132 to the specified data. It is the default characteristic if no
133 advice is given for an open file.
135 POSIX_FADV_SEQUENTIAL
137 The application expects to access the specified data sequentially
138 from lower offsets to higher offsets.
142 The application expects to access the specified data in a random order.
146 The application expects to access the specified data in the near future.
150 The application expects that it will not access the specified data
155 The application expects to access the specified data once and then
156 not reuse it thereafter.
159 The structure \fBflock\fP describes a file lock. It shall include
160 the following members:
165 \fBshort l_type \fP Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. \fB
166 short l_whence\fP Flag for starting offset. \fB
167 off_t l_start \fP Relative offset in bytes. \fB
168 off_t l_len \fP Size; if 0 then until EOF. \fB
169 pid_t l_pid \fP Process ID of the process holding the lock; returned with F_GETLK. \fB
174 The \fBmode_t\fP, \fBoff_t\fP, and \fBpid_t\fP types shall be defined
175 as described in \fI<sys/types.h>\fP .
177 The following shall be declared as functions and may also be defined
178 as macros. Function prototypes shall be provided.
183 \fBint creat(const char *, mode_t);
184 int fcntl(int, int, ...);
185 int open(const char *, int, ...);
187 int posix_fadvise(int, off_t, size_t, int);
188 int posix_fallocate(int, off_t, size_t);
194 Inclusion of the \fI<fcntl.h>\fP header may also make visible all
195 symbols from \fI<sys/stat.h>\fP and \fI<unistd.h>\fP.
197 \fIThe following sections are informative.\fP
198 .SH APPLICATION USAGE
204 .SH FUTURE DIRECTIONS
209 \fI<sys/stat.h>\fP , \fI<sys/types.h>\fP , \fI<unistd.h>\fP , the
210 System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIcreat\fP(),
211 \fIexec\fP, \fIfcntl\fP(), \fIopen\fP(), \fIposix_fadvise\fP(), \fIposix_fallocate\fP(),
212 \fIposix_madvise\fP()
214 Portions of this text are reprinted and reproduced in electronic form
215 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
216 -- Portable Operating System Interface (POSIX), The Open Group Base
217 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
218 Electrical and Electronics Engineers, Inc and The Open Group. In the
219 event of any discrepancy between this version and the original IEEE and
220 The Open Group Standard, the original IEEE and The Open Group Standard
221 is the referee document. The original Standard can be obtained online at
222 http://www.opengroup.org/unix/online.html .