.\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .TH fcntl 2 2025-07-20 "Linux man-pages 6.15" .SH NAME fcntl \- manipulate file descriptor .SH LIBRARY Standard C library .RI ( libc ,\~ \-lc ) .SH SYNOPSIS .nf .B #include .P .BI "int fcntl(int " fd ", int " op ", ...);" .fi .SH DESCRIPTION .BR fcntl () performs one of the operations described below on the open file descriptor .IR fd . The operation is determined by .IR op . .P 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 .BR fcntl () with the desired .I op value and then test whether the call failed with .BR EINVAL , indicating that the kernel does not recognize this value. .SS Duplicating a file descriptor .TP .BR F_DUPFD (2const) .TQ .BR F_DUPFD_CLOEXEC (2const) .SS File descriptor flags .TP .BR F_GETFD (2const) .TQ .BR F_SETFD (2const) .SS File status flags .TP .BR F_GETFL (2const) .TQ .BR F_SETFL (2const) .SS Advisory record locking .TP .BR F_SETLK (2const) .TQ .BR F_SETLKW (2const) .TQ .BR F_GETLK (2const) .SS Open file description locks (non-POSIX) .TP .BR F_OFD_SETLK (2const) .TQ .BR F_OFD_SETLKW (2const) .TQ .BR F_OFD_GETLK (2const) .SS Managing signals .TP .BR F_GETOWN (2const) .TQ .BR F_SETOWN (2const) .TQ .BR F_GETOWN_EX (2const) .TQ .BR F_SETOWN_EX (2const) .TQ .BR F_GETSIG (2const) .TQ .BR F_SETSIG (2const) .SS Leases .TP .BR F_SETLEASE (2const) .TQ .BR F_GETLEASE (2const) .SS File and directory change notification (dnotify) .TP .BR F_NOTIFY (2const) .SS Changing the capacity of a pipe .TP .BR F_SETPIPE_SZ (2const) .TQ .BR F_GETPIPE_SZ (2const) .SS File Sealing .TP .BR F_ADD_SEALS (2const) .TQ .BR F_GET_SEALS (2const) .SS File read/write hints .TP .BR F_GET_RW_HINT (2const) .TQ .BR F_SET_RW_HINT (2const) .TQ .BR F_GET_FILE_RW_HINT (2const) .TQ .BR F_SET_FILE_RW_HINT (2const) .SH RETURN VALUE For a successful call, the return value depends on the operation. .P On error, \-1 is returned, and .I errno is set to indicate the error. .SH ERRORS .TP .BR EACCES " or " EAGAIN Operation is prohibited by locks held by other processes. .TP .B EAGAIN The operation is prohibited because the file has been memory-mapped by another process. .TP .B EBADF .I fd is not an open file descriptor .TP .B EINVAL The value specified in .I op is not recognized by this kernel. .SH VERSIONS POSIX.1-2024 specifies .B FD_CLOFORK and .BR F_DUPFD_CLOFORK , but Linux doesn't support them. .SH STANDARDS POSIX.1-2008. .\" .P .\" SVr4 documents additional EIO, ENOLINK and EOVERFLOW error conditions. .SH HISTORY SVr4, 4.3BSD, POSIX.1-2001. .SH SEE ALSO .BR dup2 (2), .BR flock (2), .BR open (2), .BR socket (2), .BR lockf (3), .BR capabilities (7), .BR feature_test_macros (7), .BR lslocks (8)