summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/fcntl.2
diff options
context:
space:
mode:
authorantoine <antoine@FreeBSD.org>2008-03-08 22:02:21 +0000
committerantoine <antoine@FreeBSD.org>2008-03-08 22:02:21 +0000
commit514f31f40ed28fea8fdc190c743417debb0d03b3 (patch)
treea5c6d546b6b95056f3d9779f9c1afae2cec004f6 /lib/libc/sys/fcntl.2
parent587a314ce88f943ab58c211714655de88ddbdd25 (diff)
downloadFreeBSD-src-514f31f40ed28fea8fdc190c743417debb0d03b3.zip
FreeBSD-src-514f31f40ed28fea8fdc190c743417debb0d03b3.tar.gz
Introduce a new F_DUP2FD command to fcntl(2), for compatibility with
Solaris and AIX. fcntl(fd, F_DUP2FD, arg) and dup2(fd, arg) are functionnaly equivalent. Document it. Add some regression tests (identical to the dup2(2) regression tests). PR: 120233 Submitted by: Jukka Ukkonen Approved by: rwaston (mentor) MFC after: 1 month
Diffstat (limited to 'lib/libc/sys/fcntl.2')
-rw-r--r--lib/libc/sys/fcntl.238
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
index a476cff..aef53e2 100644
--- a/lib/libc/sys/fcntl.2
+++ b/lib/libc/sys/fcntl.2
@@ -28,7 +28,7 @@
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\" $FreeBSD$
.\"
-.Dd January 12, 1994
+.Dd March 8, 2008
.Dt FCNTL 2
.Os
.Sh NAME
@@ -78,6 +78,18 @@ is set to remain open across
.Xr execve 2
system calls.
.El
+.It Dv F_DUP2FD
+It is functionally equivalent to
+.Bd -literal -offset indent
+dup2(fd, arg)
+.Ed
+.Pp
+The
+.Dv F_DUP2FD
+constant is not portable, so it should not be used if portability is needed.
+Use
+.Fn dup2
+instead.
.It Dv F_GETFD
Get the close-on-exec flag associated with the file descriptor
.Fa fd
@@ -389,6 +401,9 @@ as follows:
.Bl -tag -width F_GETOWNX -offset indent
.It Dv F_DUPFD
A new file descriptor.
+.It Dv F_DUP2FD
+A file descriptor equal to
+.Fa arg .
.It Dv F_GETFD
Value of flag (only the low-order bit is defined).
.It Dv F_GETFL
@@ -432,6 +447,14 @@ is not a valid open file descriptor.
The argument
.Fa cmd
is
+.Dv F_DUP2FD ,
+and
+.Fa arg
+is not a valid file descriptor.
+.Pp
+The argument
+.Fa cmd
+is
.Dv F_SETLK
or
.Dv F_SETLKW ,
@@ -495,6 +518,8 @@ The argument
.Fa cmd
is
.Dv F_DUPFD
+or
+.Dv F_DUP2FD
and the maximum number of file descriptors permitted for the
process are already in use,
or no file descriptors greater than or equal to
@@ -567,6 +592,7 @@ for the reasons as stated in
.Xr tcgetpgrp 3 .
.Sh SEE ALSO
.Xr close 2 ,
+.Xr dup2 2 ,
.Xr execve 2 ,
.Xr flock 2 ,
.Xr getdtablesize 2 ,
@@ -575,8 +601,18 @@ for the reasons as stated in
.Xr lockf 3 ,
.Xr tcgetpgrp 3 ,
.Xr tcsetpgrp 3
+.Sh STANDARDS
+The
+.Dv F_DUP2FD
+constant is non portable.
+It is provided for compatibility with AIX and Solaris.
.Sh HISTORY
The
.Fn fcntl
system call appeared in
.Bx 4.2 .
+.Pp
+The
+.Dv F_DUP2FD
+constant first appeared in
+.Fx 7.1 .
OpenPOWER on IntegriCloud