--- old/usr/src/cmd/truss/codes.c	Tue Apr  2 01:24:37 2013
+++ new/usr/src/cmd/truss/codes.c	Tue Apr  2 01:24:37 2013
@@ -24,6 +24,7 @@
  * Copyright (c) 2012 by Delphix. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
@@ -1918,7 +1919,7 @@
 #define	ALL_O_FLAGS \
 	(O_NDELAY|O_APPEND|O_SYNC|O_DSYNC|O_NONBLOCK|O_CREAT|O_TRUNC\
 	|O_EXCL|O_NOCTTY|O_LARGEFILE|O_RSYNC|O_XATTR|O_NOFOLLOW|O_NOLINKS\
-	|FXATTRDIROPEN)
+	|O_CLOEXEC|FXATTRDIROPEN)
 
 const char *
 openarg(private_t *pri, int arg)
@@ -1976,6 +1977,8 @@
 		(void) strlcat(str, "|O_NOFOLLOW", sizeof (pri->code_buf));
 	if (arg & O_NOLINKS)
 		(void) strlcat(str, "|O_NOLINKS", sizeof (pri->code_buf));
+	if (arg & O_CLOEXEC)
+		(void) strlcat(str, "|O_CLOEXEC", sizeof (pri->code_buf));
 	if (arg & FXATTRDIROPEN)
 		(void) strlcat(str, "|FXATTRDIROPEN", sizeof (pri->code_buf));
 
--- old/usr/src/man/man2/open.2	Tue Apr  2 01:24:37 2013
+++ new/usr/src/man/man2/open.2	Tue Apr  2 01:24:37 2013
@@ -2,6 +2,7 @@
 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
 .\" Copyright 1989 AT&T
 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
+.\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc.  All Rights Reserved.
 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
 .\" http://www.opengroup.org/bookstore/.
 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
@@ -211,6 +212,17 @@
 sets \fBerrno\fR to \fBEMLINK\fR.
 .RE
 
+.sp
+.ne 2
+.na
+\fB\fBO_CLOEXEC\fR\fR
+.ad
+.sp .6
+.RS 4n
+If set, the filedescriptor returned will be closed prior to any future
+\fBexec()\fR calls.
+.RE
+
 .sp
 .ne 2
 .na
--- old/usr/src/uts/common/sys/fcntl.h	Tue Apr  2 01:24:37 2013
+++ new/usr/src/uts/common/sys/fcntl.h	Tue Apr  2 01:24:37 2013
@@ -36,6 +36,8 @@
  * contributors.
  */
 
+/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
+
 #ifndef	_SYS_FCNTL_H
 #define	_SYS_FCNTL_H
 
@@ -82,6 +84,7 @@
 #define	O_XATTR		0x4000	/* extended attribute */
 #define	O_NOFOLLOW	0x20000	/* don't follow symlinks */
 #define	O_NOLINKS	0x40000	/* don't allow multiple hard links */
+#define	O_CLOEXEC	0x800000	/* set the close-on-exec flag */
 
 /*
  * fcntl(2) requests
--- old/usr/src/uts/common/sys/file.h	Tue Apr  2 01:24:37 2013
+++ new/usr/src/uts/common/sys/file.h	Tue Apr  2 01:24:37 2013
@@ -26,6 +26,8 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
+/* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
+
 #ifndef _SYS_FILE_H
 #define	_SYS_FILE_H
 
@@ -113,6 +115,8 @@
 #define	FSEARCH		0x200000	/* O_SEARCH = 0x200000 */
 #define	FEXEC		0x400000	/* O_EXEC = 0x400000 */
 
+#define	FCLOEXEC	0x800000 /* O_CLOEXEC = 0x800000 */
+
 #ifdef _KERNEL
 
 /*
--- old/usr/src/uts/common/syscall/open.c	Tue Apr  2 01:24:37 2013
+++ new/usr/src/uts/common/syscall/open.c	Tue Apr  2 01:24:37 2013
@@ -27,6 +27,9 @@
 /*	  All Rights Reserved  	*/
 
 /*
+ * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
+ */
+/*
  * Portions of this source code were derived from Berkeley 4.3 BSD
  * under license from the Regents of the University of California.
  */
@@ -226,6 +229,9 @@
 					 * falloc reserved.
 					 */
 					setf(fd, fp);
+					if ((filemode & FCLOEXEC) != 0) {
+						f_setfd(fd, FD_CLOEXEC);
+					}
 					return (fd);
 				} else {
 					/*
@@ -252,6 +258,9 @@
 					fp->f_count++;
 					mutex_exit(&fp->f_tlock);
 					setf(fd, fp);
+					if ((filemode & FCLOEXEC) != 0) {
+						f_setfd(fd, FD_CLOEXEC);
+					}
 					releasef(dupfd);
 				}
 				return (fd);
