]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/man2/fcntl.2, man/man2const/F_GETFD.2const: Split F_{G,S}ETFD from fcntl(2)
authorAlejandro Colomar <alx@kernel.org>
Sat, 12 Jul 2025 12:43:56 +0000 (14:43 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sat, 19 Jul 2025 21:30:01 +0000 (23:30 +0200)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man2/fcntl.2
man/man2const/F_GETFD.2const [new file with mode: 0644]

index 6c7fe808be84d66bcdb8ba3fa53efba08e02cbfe..78e2c74e48131a48a4faad7a07864ffe9aa7cd09 100644 (file)
@@ -51,47 +51,10 @@ indicating that the kernel does not recognize this value.
 .TQ
 .BR F_DUPFD_CLOEXEC (2const)
 .SS File descriptor flags
-The following operations manipulate the flags associated with
-a file descriptor.
-Currently, only one such flag is defined:
-.BR FD_CLOEXEC ,
-the close-on-exec flag.
-If the
-.B FD_CLOEXEC
-bit is set,
-the file descriptor will automatically be closed during a successful
-.BR execve (2).
-(If the
-.BR execve (2)
-fails, the file descriptor is left open.)
-If the
-.B FD_CLOEXEC
-bit is not set, the file descriptor will remain open across an
-.BR execve (2).
-.TP
-.BR F_GETFD \~(\f[I]void\f[])
-Return (as the function result) the file descriptor flags;
-.I arg
-is ignored.
 .TP
-.BR F_SETFD \~(\f[I]int\f[])
-Set the file descriptor flags to the value specified by
-.IR arg .
-.P
-In multithreaded programs, using
-.BR fcntl ()
-.B F_SETFD
-to set the close-on-exec flag at the same time as another thread performs a
-.BR fork (2)
-plus
-.BR execve (2)
-is vulnerable to a race condition that may unintentionally leak
-the file descriptor to the program executed in the child process.
-See the discussion of the
-.B O_CLOEXEC
-flag in
-.BR open (2)
-for details and a remedy to the problem.
+.BR F_GETFD (2const)
+.TQ
+.BR F_SETFD (2const)
 .SS File status flags
 Each open file description has certain associated status flags,
 initialized by
@@ -1537,9 +1500,6 @@ and no individual absolute meaning should be attributed to them.
 .SH RETURN VALUE
 For a successful call, the return value depends on the operation:
 .TP
-.B F_GETFD
-Value of file descriptor flags.
-.TP
 .B F_GETFL
 Value of file status flags.
 .TP
@@ -1762,8 +1722,6 @@ are Linux-specific.
 SVr4, 4.3BSD, POSIX.1-2001.
 .P
 Only the operations
-.BR F_GETFD ,
-.BR F_SETFD ,
 .BR F_GETFL ,
 .BR F_SETFL ,
 .BR F_GETLK ,
diff --git a/man/man2const/F_GETFD.2const b/man/man2const/F_GETFD.2const
new file mode 100644 (file)
index 0000000..3069645
--- /dev/null
@@ -0,0 +1,82 @@
+.\" Copyright, the authors of the Linux man-pages project
+.\"
+.\" SPDX-License-Identifier: Linux-man-pages-copyleft
+.\"
+.TH F_GETFD 2const (date) "Linux man-pages (unreleased)"
+.SH NAME
+F_GETFD,
+F_SETFD
+\-
+get/set file descriptor flags
+.SH LIBRARY
+Standard C library
+.RI ( libc ,\~ \-lc )
+.SH SYNOPSIS
+.nf
+.B #include <fcntl.h>
+.P
+.BI "int fcntl(int " fd ", F_GETFD);"
+.BI "int fcntl(int " fd ", F_SETFD, int " arg );
+.fi
+.SH DESCRIPTION
+The following operations manipulate the flags associated with
+a file descriptor.
+Currently, only one such flag is defined:
+.BR FD_CLOEXEC ,
+the close-on-exec flag.
+If the
+.B FD_CLOEXEC
+bit is set,
+the file descriptor will automatically be closed during a successful
+.BR execve (2).
+(If the
+.BR execve (2)
+fails, the file descriptor is left open.)
+If the
+.B FD_CLOEXEC
+bit is not set, the file descriptor will remain open across an
+.BR execve (2).
+.TP
+.B F_GETFD
+Return (as the function result) the file descriptor flags;
+.I arg
+is ignored.
+.TP
+.B F_SETFD
+Set the file descriptor flags to the value specified by
+.IR arg .
+.SH RETURN VALUE
+.TP
+.B F_GETFD
+Value of file descriptor flags.
+.TP
+.B F_SETFD
+Zero.
+.P
+On error, \-1 is returned, and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+See
+.BR fcntl (2).
+.SH STANDARDS
+POSIX.1-2008.
+.SH HISTORY
+SVr4, 4.3BSD, POSIX.1-2001.
+.SH CAVEATS
+In multithreaded programs, using
+.BR fcntl ()
+.B F_SETFD
+to set the close-on-exec flag at the same time as another thread performs a
+.BR fork (2)
+plus
+.BR execve (2)
+is vulnerable to a race condition that may unintentionally leak
+the file descriptor to the program executed in the child process.
+See the discussion of the
+.B O_CLOEXEC
+flag in
+.BR open (2)
+for details and a remedy to the problem.
+.SH SEE ALSO
+.BR fcntl (2)