fcntl.h - file control options
The <fcntl.h> header defines the following requests and arguments for use by the functions fcntl() and open().
Values for cmd used by fcntl() (the following values are unique):
- Duplicate file descriptor.
- Get file descriptor flags.
- Set file descriptor flags.
- Get file status flags and file access modes.
- Set file status flags.
- Get record locking information.
- Set record locking information.
- Set record locking information; wait if blocked.
File descriptor flags used for fcntl():
- Close the file descriptor upon execution of an exec family function.
Values for l_type used for record locking with fcntl() (the following values are unique):
- Shared or read lock.
- Exclusive or write lock.
The values used for l_whence, SEEK_SET, SEEK_CUR and SEEK_END are defined as described in <unistd.h>.
The following four sets of values for oflag used by open() are bitwise distinct:
- Create file if it does not exist.
- Exclusive use flag.
- Do not assign controlling terminal.
- Truncate flag.
File status flags used for open() and fcntl():
- Set append mode.
- Write according to synchronised I/O data integrity completion.
- Non-blocking mode.
- Synchronised read I/O operations.
- Write according to synchronised I/O file integrity completion.
Mask for use with file access modes:
- Mask for file access modes.
File access modes used for open() and fcntl():
- Open for reading only.
- Open for reading and writing.
- Open for writing only.
The symbolic names for file modes for use as values of mode_t are defined as described in <sys/stat.h>.
The structure flock describes a file lock. It includes the following members:short l_type 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 off_t and pid_t types are defined as described in <sys/types.h>.
The following are declared as functions and may also be defined as macros. Function prototypes must be provided for use with an ISO C compiler.int creat(const char *, mode_t); int fcntl(int, int, ...); int open(const char *, int, ...);
Inclusion of the <fcntl.h> header may also make visible all symbols from <sys/stat.h> and <unistd.h>.
creat(), exec, fcntl(), open(), <sys/stat.h>, <sys/types.h>, <unistd.h>.