diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-08 21:26:28 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-08 21:26:28 +0000 |
commit | 6519c3002d102ec70de253a7aabb03c5e8106c80 (patch) | |
tree | 605b694a884f6911bb72373f0dd4b1a7b6a2b7d2 | |
parent | b79efb32670cb265a51bdf337b48be5595df0209 (diff) |
Add F_DUPFD_CLOEXEC.
"Sure" deraadt@
-rw-r--r-- | sys/kern/kern_descrip.c | 6 | ||||
-rw-r--r-- | sys/sys/fcntl.h | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 7ead57404e6..cb4b4143361 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.87 2011/07/08 19:28:36 otto Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.88 2011/07/08 21:26:27 matthew Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -313,6 +313,7 @@ restart: switch (SCARG(uap, cmd)) { case F_DUPFD: + case F_DUPFD_CLOEXEC: newmin = (long)SCARG(uap, arg); if ((u_int)newmin >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur || (u_int)newmin >= maxfiles) { @@ -334,6 +335,9 @@ restart: else FRELE(fp); + if (!error && SCARG(uap, cmd) == F_DUPFD_CLOEXEC) + fdp->fd_ofileflags[i] |= UF_EXCLOSE; + fdpunlock(fdp); return (error); diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 79dea96d705..f14b27cc3c3 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fcntl.h,v 1.14 2011/07/08 04:23:24 matthew Exp $ */ +/* $OpenBSD: fcntl.h,v 1.15 2011/07/08 21:26:27 matthew Exp $ */ /* $NetBSD: fcntl.h,v 1.8 1995/03/26 20:24:12 jtc Exp $ */ /*- @@ -153,6 +153,9 @@ #define F_GETLK 7 /* get record locking information */ #define F_SETLK 8 /* set record locking information */ #define F_SETLKW 9 /* F_SETLK; wait if blocked */ +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +#define F_DUPFD_CLOEXEC 10 /* duplicate with FD_CLOEXEC set */ +#endif /* file descriptor flags (F_GETFD, F_SETFD) */ #define FD_CLOEXEC 1 /* close-on-exec flag */ |