fcntl2
Manipulate file descriptor
Usage
#include <fcntl.h>
int fcntl(int fd, int op, ...);
Library
Standard C library (libc, -lc)
Overview
fcntl() performs one of the operations described below on the open file descriptor fd. The operation is determined by op.
Certain of the operations below are supported only since a particular Linux kernel version. The preferred method of checking whether the host kernel supports a particular operation is to invoke fcntl() with the desired op value and then test whether the call failed with EINVAL, indicating that the kernel does not recognize this value.
Duplicating a file descriptor
File descriptor flags
File status flags
Advisory record locking
Open file description locks (non-POSIX)
Managing signals
Leases
Delegations
File and directory change notification (dnotify)
Changing the capacity of a pipe
File Sealing
File read/write hints
Return value
For a successful call, the return value depends on the operation.
On error, -1 is returned, and errno is set to indicate the error.
Errors
- EACCES or EAGAIN
-
Operation is prohibited by locks held by other processes.
- EAGAIN
-
The operation is prohibited because the file has been memory-mapped by another process.
- EBADF
-
fd is not an open file descriptor
- EINVAL
-
The value specified in op is not recognized by this kernel.
Versions
POSIX.1-2024 specifies FD_CLOFORK and F_DUPFD_CLOFORK, but Linux doesn't support them.
Releases
19 releases since Debian 1.1 (Buzz); the text changed 17 times.