1<fcntl.h>(P)               POSIX Programmer's Manual              <fcntl.h>(P)
2
3
4

NAME

6       fcntl.h - file control options
7

SYNOPSIS

9       #include <fcntl.h>
10

DESCRIPTION

12       The  <fcntl.h> header shall define the following requests and arguments
13       for use by the functions fcntl() and open().
14
15       Values for cmd used by fcntl() (the following values are unique) are as
16       follows:
17
18       F_DUPFD
19              Duplicate file descriptor.
20
21       F_GETFD
22              Get file descriptor flags.
23
24       F_SETFD
25              Set file descriptor flags.
26
27       F_GETFL
28              Get file status flags and file access modes.
29
30       F_SETFL
31              Set file status flags.
32
33       F_GETLK
34              Get record locking information.
35
36       F_SETLK
37              Set record locking information.
38
39       F_SETLKW
40              Set record locking information; wait if blocked.
41
42       F_GETOWN
43              Get process or process group ID to receive SIGURG signals.
44
45       F_SETOWN
46              Set process or process group ID to receive SIGURG signals.
47
48
49       File descriptor flags used for fcntl() are as follows:
50
51       FD_CLOEXEC
52              Close the file descriptor upon execution of an exec family func‐
53              tion.
54
55
56       Values for l_type used for record locking with fcntl()  (the  following
57       values are unique) are as follows:
58
59       F_RDLCK
60              Shared or read lock.
61
62       F_UNLCK
63              Unlock.
64
65       F_WRLCK
66              Exclusive or write lock.
67
68
69       The values used for l_whence, SEEK_SET, SEEK_CUR, and SEEK_END shall be
70       defined as described in <unistd.h> .
71
72       The following values are file creation flags and are used in the  oflag
73       value to open(). They shall be bitwise-distinct.
74
75       O_CREAT
76              Create file if it does not exist.
77
78       O_EXCL Exclusive use flag.
79
80       O_NOCTTY
81              Do not assign controlling terminal.
82
83       O_TRUNC
84              Truncate flag.
85
86
87       File status flags used for open() and fcntl() are as follows:
88
89       O_APPEND
90              Set append mode.
91
92       O_DSYNC
93              Write according to synchronized I/O data integrity completion.
94
95       O_NONBLOCK
96              Non-blocking mode.
97
98       O_RSYNC
99              Synchronized read I/O operations.
100
101       O_SYNC Write according to synchronized I/O file integrity completion.
102
103
104       Mask for use with file access modes is as follows:
105
106       O_ACCMODE
107              Mask for file access modes.
108
109
110       File access modes used for open() and fcntl() are as follows:
111
112       O_RDONLY
113              Open for reading only.
114
115       O_RDWR Open for reading and writing.
116
117       O_WRONLY
118              Open for writing only.
119
120
121       The  symbolic names for file modes for use as values of mode_t shall be
122       defined as described in <sys/stat.h> .
123
124       Values for advice used by posix_fadvise() are as follows:
125
126       POSIX_FADV_NORMAL
127
128              The application has no advice  to  give  on  its  behavior  with
129              respect  to the specified data. It is the default characteristic
130              if no advice is given for an open file.
131
132       POSIX_FADV_SEQUENTIAL
133
134              The application expects to access  the  specified  data  sequen‐
135              tially from lower offsets to higher offsets.
136
137       POSIX_FADV_RANDOM
138
139              The application expects to access the specified data in a random
140              order.
141
142       POSIX_FADV_WILLNEED
143
144              The application expects to access the specified data in the near
145              future.
146
147       POSIX_FADV_DONTNEED
148
149              The  application  expects  that it will not access the specified
150              data in the near future.
151
152       POSIX_FADV_NOREUSE
153
154              The application expects to access the specified  data  once  and
155              then not reuse it thereafter.
156
157
158       The structure flock describes a file lock. It shall include the follow‐
159       ing members:
160
161
162              short  l_type   Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
163              short  l_whence Flag for starting offset.
164              off_t  l_start  Relative offset in bytes.
165              off_t  l_len    Size; if 0 then until EOF.
166              pid_t  l_pid    Process ID of the process holding the lock; returned with F_GETLK.
167
168       The mode_t, off_t, and pid_t types shall be  defined  as  described  in
169       <sys/types.h> .
170
171       The following shall be declared as functions and may also be defined as
172       macros. Function prototypes shall be provided.
173
174
175              int  creat(const char *, mode_t);
176              int  fcntl(int, int, ...);
177              int  open(const char *, int, ...);
178
179              int  posix_fadvise(int, off_t, size_t, int);
180              int  posix_fallocate(int, off_t, size_t);
181
182
183       Inclusion of the <fcntl.h> header may also  make  visible  all  symbols
184       from <sys/stat.h> and <unistd.h>.
185
186       The following sections are informative.
187

APPLICATION USAGE

189       None.
190

RATIONALE

192       None.
193

FUTURE DIRECTIONS

195       None.
196

SEE ALSO

198       <sys/stat.h>  , <sys/types.h> , <unistd.h> , the System Interfaces vol‐
199       ume of IEEE Std 1003.1-2001, creat(), exec, fcntl(), open(), posix_fad‐
200       vise(), posix_fallocate(), posix_madvise()
201
203       Portions  of  this text are reprinted and reproduced in electronic form
204       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
205       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
206       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
207       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
208       event of any discrepancy between this version and the original IEEE and
209       The  Open Group Standard, the original IEEE and The Open Group Standard
210       is the referee document. The original Standard can be  obtained  online
211       at http://www.opengroup.org/unix/online.html .
212
213
214
215IEEE/The Open Group                  2003                         <fcntl.h>(P)
Impressum