.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
.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
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 ,
--- /dev/null
+.\" 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)