svn commit: r238834 - in head/sys: kern sys

Konstantin Belousov kib at FreeBSD.org
Fri Jul 27 10:41:11 UTC 2012


Author: kib
Date: Fri Jul 27 10:41:10 2012
New Revision: 238834
URL: http://svn.freebsd.org/changeset/base/238834

Log:
  Add F_DUP2FD_CLOEXEC.  Apparently Solaris 11 already did this.
  
  Submitted by:	Jukka A. Ukkonen <jau iki fi>
  PR:	standards/169962
  MFC after:	1 week

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/fcntl.h

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Fri Jul 27 10:39:30 2012	(r238833)
+++ head/sys/kern/kern_descrip.c	Fri Jul 27 10:41:10 2012	(r238834)
@@ -491,6 +491,12 @@ kern_fcntl(struct thread *td, int fd, in
 		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 = fget_locked(fdp, fd)) == NULL) {
@@ -849,6 +855,8 @@ do_dup(struct thread *td, int flags, int
 	}
 	if (flags & DUP_FIXED && old == new) {
 		*retval = new;
+		if (flags & DUP_CLOEXEC)
+			fdp->fd_ofileflags[new] |= UF_EXCLOSE;
 		FILEDESC_XUNLOCK(fdp);
 		return (0);
 	}

Modified: head/sys/sys/fcntl.h
==============================================================================
--- head/sys/sys/fcntl.h	Fri Jul 27 10:39:30 2012	(r238833)
+++ head/sys/sys/fcntl.h	Fri Jul 27 10:41:10 2012	(r238834)
@@ -232,6 +232,9 @@ typedef	__pid_t		pid_t;
 #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 svn-src-all mailing list