svn commit: r239857 - in stable/9/sys: kern sys
Konstantin Belousov
kib at FreeBSD.org
Wed Aug 29 16:23:30 UTC 2012
Author: kib
Date: Wed Aug 29 16:23:29 2012
New Revision: 239857
URL: http://svn.freebsd.org/changeset/base/239857
Log:
MFC r238834:
Add F_DUP2FD_CLOEXEC.
PR: standards/169962
Modified:
stable/9/sys/kern/kern_descrip.c
stable/9/sys/sys/fcntl.h
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/kern/kern_descrip.c
==============================================================================
--- stable/9/sys/kern/kern_descrip.c Wed Aug 29 16:17:02 2012 (r239856)
+++ stable/9/sys/kern/kern_descrip.c Wed Aug 29 16:23:29 2012 (r239857)
@@ -498,6 +498,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 = fdtofp(fd, fdp)) == NULL) {
@@ -836,6 +842,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: stable/9/sys/sys/fcntl.h
==============================================================================
--- stable/9/sys/sys/fcntl.h Wed Aug 29 16:17:02 2012 (r239856)
+++ stable/9/sys/sys/fcntl.h Wed Aug 29 16:23:29 2012 (r239857)
@@ -228,6 +228,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-stable-9
mailing list