| NAME | LIBRARY | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | VERSIONS | STANDARDS | HISTORY | SEE ALSO | COLOPHON | |
|  | 
fcntl(2)                   System Calls Manual                   fcntl(2)
       fcntl - manipulate file descriptor
       Standard C library (libc, -lc)
       #include <fcntl.h>
       int fcntl(int fd, int op, ...);
       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
       F_DUPFD(2const)
       F_DUPFD_CLOEXEC(2const)
   File descriptor flags
       F_GETFD(2const)
       F_SETFD(2const)
   File status flags
       F_GETFL(2const)
       F_SETFL(2const)
   Advisory record locking
       F_SETLK(2const)
       F_SETLKW(2const)
       F_GETLK(2const)
   Open file description locks (non-POSIX)
       F_OFD_SETLK(2const)
       F_OFD_SETLKW(2const)
       F_OFD_GETLK(2const)
   Managing signals
       F_GETOWN(2const)
       F_SETOWN(2const)
       F_GETOWN_EX(2const)
       F_SETOWN_EX(2const)
       F_GETSIG(2const)
       F_SETSIG(2const)
   Leases
       F_SETLEASE(2const)
       F_GETLEASE(2const)
   File and directory change notification (dnotify)
       F_NOTIFY(2const)
   Changing the capacity of a pipe
       F_SETPIPE_SZ(2const)
       F_GETPIPE_SZ(2const)
   File Sealing
       F_ADD_SEALS(2const)
       F_GET_SEALS(2const)
   File read/write hints
       F_GET_RW_HINT(2const)
       F_SET_RW_HINT(2const)
       F_GET_FILE_RW_HINT(2const)
       F_SET_FILE_RW_HINT(2const)
       For a successful call, the return value depends on the operation.
       On error, -1 is returned, and errno is set to indicate the error.
       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.
       POSIX.1-2024 specifies FD_CLOFORK and F_DUPFD_CLOFORK, but Linux
       doesn't support them.
       POSIX.1-2008.
       SVr4, 4.3BSD, POSIX.1-2001.
       dup2(2), flock(2), open(2), socket(2), lockf(3), capabilities(7),
       feature_test_macros(7), lslocks(8)
       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.15.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2025-08-11.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       [email protected]
Linux man-pages 6.15            2025-07-20                       fcntl(2)
Pages that refer to this page: flock(1), pipesz(1), accept(2), bpf(2), chmod(2), clone(2), close(2), dup(2), eventfd(2), execve(2), fallocate(2), fcntl_locking(2), F_DUPFD(2const), F_GETFD(2const), F_GETFL(2const), F_GETLEASE(2const), F_GETPIPE_SZ(2const), F_GET_RW_HINT(2const), F_GET_SEALS(2const), F_GETSIG(2const), flock(2), F_NOTIFY(2const), fork(2), getrlimit(2), gettid(2), inotify_init(2), ioctl(2), ioctl_console(2), memfd_create(2), memfd_secret(2), mknod(2), mmap(2), mount(2), NS_GET_USERNS(2const), open(2), perf_event_open(2), pidfd_getfd(2), pipe(2), read(2), recv(2), select_tut(2), send(2), sigaction(2), signalfd(2), socket(2), statfs(2), syscalls(2), timerfd_create(2), truncate(2), userfaultfd(2), write(2), audit_open(3), dbopen(3), fopen(3), lockf(3), sd_event_add_io(3), shm_open(3), sockatmark(3), statvfs(3), nfs(5), proc_locks(5), proc_sys_fs(5), systemd.socket(5), capabilities(7), credentials(7), epoll(7), inotify(7), landlock(7), man-pages(7), pipe(7), pthreads(7), signal(7), signal-safety(7), socket(7), tcp(7), lslocks(8), mount(8)