fcntl(5)
NAME
fcntl − file control options
SYNOPSIS
#include <sys/types.h>
#include <fcntl.h>
DESCRIPTION
The fcntl() function provides for control over open files. The <fcntl.h> include file describes requests and arguments to fcntl() and open(). See fcntl(2) and open(2).
The access modes set by open() and accessed by fcntl() are:
O_RDONLY
O_WRONLY
O_RDWR
The mask for file access modes is:
O_ACCMODE
The file status flags set by open() or fcntl() and accessed by fcntl() are:
O_NDELAY Nonblocking I/O.
O_NONBLOCK POSIX-style nonblocking I/O.
O_APPEND Append (writes guaranteed at the end).
O_DSYNC Write through cache for data.
O_SYNC Write through cache for data and attributes.
O_RSYNC|O_DSYNC Write through cache for data on reads and writes.
O_RSYNC|O_SYNC Write through cache for data and attributes on reads and writes.
The flag O_SYNCIO is a synonym for O_SYNC and is defined for backward compatibility in <fcntl.h>.
The flag values accessible only to open() are:
O_CREAT Open with file create (uses third open arg).
O_TRUNC Open with truncation.
O_EXCL Exclusive open.
O_NOCTTY Do not assign a controlling terminal.
The requests for fcntl() are:
F_DUPFD Duplicate file descriptor.
F_GETFD Get file descriptor flags.
F_SETFD Set file descriptor flags.
F_GETFL Get file flags.
F_SETFL Set file flags.
F_GETLK Get blocking file lock.
F_SETLK Set or clear file locks and fail on busy.
F_SETLKW Set or clear file locks and wait on busy.
The file descriptor flag for F_GETFD, F_SETFD is:
FD_CLOEXEC
The file segment locking control structure struct flock, includes the following members:
short l_type; /* F_RDLCK, F_WRLCK or F_UNLCK */
short l_whence; /* Flag - see lseek(2) */
off_t l_start; /* Relative offset in bytes */
off_t l_len; /* Size; if 0 then until EOF */
pid_t l_pid; /* By F_GETLK - process holding lock */
The file segment locking types are:
F_RDLCK Read lock.
F_WRLCK Write lock.
F_UNLCK Remove locks.
SEE ALSO
STANDARDS CONFORMANCE
<fcntl.h>: AES, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
Hewlett-Packard Company — HP-UX Release 10.20: July 1996