fcntl(5) fcntl(5)NAME fcntl - file control options SYNOPSIS #include <fcntl.h> DESCRIPTION fcntl(2) provides for control over open files. The include file describes requests and arguments to fcntl(2) and open(2). #ifndef __fcntl_h #define __fcntl_h /* POSIX requires types; most applications don't do this yet! */ #ifndef __sys_types_h #include <sys/types.h> #endif /* !__sys_types_h */ /* Flag values accessible to open(2) and fcntl(2) */ /* (The first three can only be set by open) */ #if defined(_SYSV_SOURCE) || defined(_POSIX_SOURCE) #ifndef __sys_file_h #define O_RDONLY 0 #define O_WRONLY 1 #define O_RDWR 2 #define O_APPEND 010 /* append (writes guaranteed at the end) */ /* Flag values accessible only to open(2) */ #define O_CREAT 00400 /* open with file create (uses third open arg) */ #define O_TRUNC 01000 /* open with truncation */ #define O_EXCL 02000 /* exclusive open */ /* fcntl(2) requests */ #define F_DUPFD 0 /* Duplicate fildes */ #define F_GETFD 1 /* Get fildes flags */ #define F_SETFD 2 /* Set fildes flags */ #define F_GETFL 3 /* Get file flags */ #define F_SETFL 4 /* Set file flags */ #define F_GETLK 5 /* Get file lock */ #define F_SETLK 6 /* Set file lock */ #define F_SETLKW 7 /* Set file lock and wait */ /* file segment locking set data type - information passed */ /* to system by user */ struct flock { short l_type; short l_whence; long l_start; long l_len; /* len = 0 means until end of file */ January 1992 1
fcntl(5) fcntl(5)int l_pid; }; /* file segment locking types */ #define F_RDLCK 01 /* Read lock */ #define F_WRLCK 02 /* Write lock */ #define F_UNLCK 03 /* Remove locks */ #endif /* _SYSV_SOURCE || _POSIX_SOURCE */ #ifdef _BSD_SOURCE /* Additional fcntl(2) request */ #define F_GETOWN 8 /* Get owner */ #define F_SETOWN 9 /* Set owner */ #endif /* _BSD_SOURCE */ #ifdef _POSIX_SOURCE /* File access mode mask */ #define 0_ACCMODE 03 /* POSIX-defined argument to F_SETFD */ #define FD_CLOEXEC 0x0001 /* POSIX-defined flag values accesible to open(2) and/or fcntl(2) */ #define 0_NONBLOCK 040000 /* 0_NDELAY POSIX style */ #define 0_NOCTTY 0l00000 /* don't assign controlling tty */ #endif /* _POSIX_SOURCE */ #ifdef _AUX_SOURCE /* Implementation-define flag values accessible to open(2) */ #define O_GETCTTY 0200000 /* force controlling tty assignment */ #endif /* _AUX_SOURCE */ #endif /* !__fcntl_h */ SEE ALSO fcntl(2), open(2) 2 January 1992