[Midnightbsd-cvs] src [7938] trunk/sys: add F_DUP2FD_CLOEXEC
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Sep 14 17:36:45 EDT 2016
Revision: 7938
http://svnweb.midnightbsd.org/src/?rev=7938
Author: laffer1
Date: 2016-09-14 17:36:45 -0400 (Wed, 14 Sep 2016)
Log Message:
-----------
add F_DUP2FD_CLOEXEC
Modified Paths:
--------------
trunk/sys/kern/kern_descrip.c
trunk/sys/sys/fcntl.h
Modified: trunk/sys/kern/kern_descrip.c
===================================================================
--- trunk/sys/kern/kern_descrip.c 2016-09-14 21:35:29 UTC (rev 7937)
+++ trunk/sys/kern/kern_descrip.c 2016-09-14 21:36:45 UTC (rev 7938)
@@ -498,6 +498,12 @@
error = do_dup(td, DUP_FIXED, fd, tmp, td->td_retval);
break;
+ case F_DUP2FD_CLOEXEC:
+ tmp = arg;
+ error = do_dup(td, DUP_FIXED | DUP_CLOEXEC, fd, tmp,
+ td->td_retval);
+ break;
+
case F_GETFD:
FILEDESC_SLOCK(fdp);
if ((fp = fdtofp(fd, fdp)) == NULL) {
@@ -836,6 +842,8 @@
}
if (flags & DUP_FIXED && old == new) {
*retval = new;
+ if (flags & DUP_CLOEXEC)
+ fdp->fd_ofileflags[new] |= UF_EXCLOSE;
FILEDESC_XUNLOCK(fdp);
return (0);
}
Modified: trunk/sys/sys/fcntl.h
===================================================================
--- trunk/sys/sys/fcntl.h 2016-09-14 21:35:29 UTC (rev 7937)
+++ trunk/sys/sys/fcntl.h 2016-09-14 21:36:45 UTC (rev 7938)
@@ -228,6 +228,9 @@
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
#endif
+#if __BSD_VISIBLE
+#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
+#endif
/* file descriptor flags (F_GETFD, F_SETFD) */
#define FD_CLOEXEC 1 /* close-on-exec flag */
More information about the Midnightbsd-cvs
mailing list