--- old/usr/src/head/unistd.h	Mon Apr  6 11:47:10 2015
+++ new/usr/src/head/unistd.h	Mon Apr  6 11:47:10 2015
@@ -290,6 +290,9 @@
 extern int execv(const char *, char *const *);
 extern int execve(const char *, char *const *, char *const *);
 extern int execvp(const char *, char *const *);
+#if defined(_XPG7) || !defined(_STRICT_SYMBOLS)
+extern int fexecve(int, char *const[], char *const[]);
+#endif
 extern void _exit(int)
 	__NORETURN;
 /*
--- old/usr/src/lib/libc/amd64/Makefile	Mon Apr  6 11:47:13 2015
+++ new/usr/src/lib/libc/amd64/Makefile	Mon Apr  6 11:47:13 2015
@@ -22,8 +22,8 @@
 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2015, Joyent, Inc. All rights reserved.
 #
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2013 Garrett D'Amore <garrett@damore.org>
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
@@ -860,6 +860,7 @@
 	execle.o		\
 	execv.o			\
 	fcntl.o			\
+	fexecve.o		\
 	getpagesizes.o		\
 	getpeerucred.o		\
 	inst_sync.o		\
--- old/usr/src/lib/libc/i386/Makefile.com	Mon Apr  6 11:47:16 2015
+++ new/usr/src/lib/libc/i386/Makefile.com	Mon Apr  6 11:47:16 2015
@@ -22,7 +22,7 @@
 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2015, Joyent, Inc.  All rights reserved.
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2013 Garrett D'Amore <garrett@damore.org>
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 # Use is subject to license terms.
@@ -900,6 +900,7 @@
 	execle.o		\
 	execv.o			\
 	fcntl.o			\
+	fexecve.o		\
 	getpagesizes.o		\
 	getpeerucred.o		\
 	inst_sync.o		\
--- old/usr/src/lib/libc/port/llib-lc	Mon Apr  6 11:47:16 2015
+++ new/usr/src/lib/libc/port/llib-lc	Mon Apr  6 11:47:16 2015
@@ -423,6 +423,9 @@
 /* fdetach.c */
 int fdetach(const char *path);
 
+/* fexecve.c */
+int fexecve(int, char *const argv[], char *const envp[]);
+
 /* ffs.c */
 int ffs(int field);
 
--- old/usr/src/lib/libc/port/mapfile-vers	Mon Apr  6 11:47:17 2015
+++ new/usr/src/lib/libc/port/mapfile-vers	Mon Apr  6 11:47:18 2015
@@ -28,7 +28,7 @@
 # Copyright (c) 2015, Joyent, Inc.  All rights reserved.
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
 # Copyright (c) 2013 Gary Mills
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2015 Garrett D'Amore <garrett@damore.org>
 
 #
 # MAPFILE HEADER START
@@ -93,6 +93,11 @@
 $add amd64
 $endif
 
+SYMBOL_VERSION ILLUMOS_0.12 {
+    protected:
+	fexecve;
+} ILLUMOS_0.11;
+
 SYMBOL_VERSION ILLUMOS_0.11 {	# Illumos additions
     protected:
 	iswxdigit_l;
--- /dev/null	Mon Apr  6 11:47:20 2015
+++ new/usr/src/lib/libc/port/sys/fexecve.c	Mon Apr  6 11:47:20 2015
@@ -0,0 +1,45 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
+
+#include "lint.h"
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <assert.h>
+
+#define	FDFILE	"/dev/fd/%u"
+
+/*
+ * fexecve.c - implements the fexecve function.
+ *
+ * We implement in terms of the execve() system call, but use the path
+ * /dev/fd/<fd>.  This depends on special handling in the execve system
+ * call; note that /dev/fd files are not normally directly executable.
+ * This does not actually use the fd filesystem mounted on /dev/fd.
+ */
+int
+fexecve(int fd, char *const argv[], char *const envp[])
+{
+	char path[32];	/* 8 for "/dev/fd/", 10 for %u, + \0 == 19 */
+
+	if (fcntl(fd, F_GETFL) < 0) {
+		/* This will have the effect of returning EBADF */
+		return (-1);
+	}
+	assert(snprintf(NULL, 0, FDFILE, fd) < (sizeof (path) - 1));
+	(void) snprintf(path, sizeof (path), FDFILE, fd);
+	return (execve(path, argv, envp));
+}
--- old/usr/src/lib/libc/sparc/Makefile.com	Mon Apr  6 11:47:22 2015
+++ new/usr/src/lib/libc/sparc/Makefile.com	Mon Apr  6 11:47:22 2015
@@ -22,7 +22,7 @@
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2015, Joyent, Inc.  All rights reserved.
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2013 Garrett D'Amore <garrett@damore.org>
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 # Use is subject to license terms.
@@ -934,6 +934,7 @@
 	execle.o		\
 	execv.o			\
 	fcntl.o			\
+	fexecve.o		\
 	getpagesizes.o		\
 	getpeerucred.o		\
 	inst_sync.o		\
--- old/usr/src/lib/libc/sparcv9/Makefile.com	Mon Apr  6 11:47:25 2015
+++ new/usr/src/lib/libc/sparcv9/Makefile.com	Mon Apr  6 11:47:25 2015
@@ -22,7 +22,7 @@
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2015, Joyent, Inc.  All rights reserved.
 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2013 Garrett D'Amore <garrett@damore.org>
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 # Use is subject to license terms.
@@ -878,6 +878,7 @@
 	execle.o		\
 	execv.o			\
 	fcntl.o			\
+	fexecve.o		\
 	getpagesizes.o		\
 	getpeerucred.o		\
 	inst_sync.o		\
--- old/usr/src/lib/libxcurses/h/mks.h	Mon Apr  6 11:47:28 2015
+++ new/usr/src/lib/libxcurses/h/mks.h	Mon Apr  6 11:47:28 2015
@@ -20,12 +20,12 @@
  * CDDL HEADER END
  */
 /*
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ *
  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * MKS header file.  Defines that make programming easier for us.
  * Includes MKS-specific things and posix routines.
@@ -336,9 +336,6 @@
 LEXTERN	void	crcccitt (ushort *, ushort);
 LEXTERN	int	eprintf (const char *, ...);
 LEXTERN	void	eputs (const char *);
-LEXTERN	pid_t	fexecve (const char *, char *const *, char *const *);
-LEXTERN	pid_t	fexecvp (const char *, char *const *);
-LEXTERN	pid_t	fexecvep (const char *, char *const *, char *const *);
 LEXTERN int	execvep (const char *, char *const *, char *const *);
 LEXTERN	int	isabsname (const char *);
 LEXTERN	const char *m_cescape (wint_t);
--- old/usr/src/man/man2/Makefile	Mon Apr  6 11:47:31 2015
+++ new/usr/src/man/man2/Makefile	Mon Apr  6 11:47:31 2015
@@ -188,6 +188,7 @@
 	 	fchown.2			\
 	 	fchownat.2			\
 	 	fchroot.2			\
+	 	fexecve.2			\
 	 	fgetlabel.2			\
 	 	fork1.2				\
 	 	forkall.2			\
@@ -296,6 +297,7 @@
 execv.2				:= LINKSRC = exec.2
 execve.2			:= LINKSRC = exec.2
 execvp.2			:= LINKSRC = exec.2
+fexecve.2			:= LINKSRC = exec.2
 
 _Exit.2				:= LINKSRC = exit.2
 _exit.2				:= LINKSRC = exit.2
--- old/usr/src/man/man2/exec.2	Mon Apr  6 11:47:33 2015
+++ new/usr/src/man/man2/exec.2	Mon Apr  6 11:47:33 2015
@@ -1,4 +1,4 @@
-'\" te
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
 .\" Copyright 1989 AT&T.
 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
@@ -9,523 +9,590 @@
 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH EXEC 2 "Jun 16, 2008"
-.SH NAME
-exec, execl, execle, execlp, execv, execve, execvp \- execute a file
-.SH SYNOPSIS
-.LP
-.nf
-#include <unistd.h>
-
-\fBint\fR \fBexecl\fR(\fBconst char *\fR\fIpath\fR, \fBconst char *\fR\fIarg0\fR, \fB\&...
-     /* const char *\fR\fIargn\fR, \fB(char *)0 */);\fR
-.fi
-
-.LP
-.nf
-\fBint\fR \fBexecv\fR(\fBconst char *\fR\fIpath\fR, \fBchar *const\fR \fIargv[]\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBexecle\fR(\fBconst char *\fR\fIpath\fR, \fBconst char *\fR\fIarg0\fR, \fB\&...
-     /* const char *\fR\fIargn\fR, \fB(char *)0\fR,\fBchar *const\fR \fIenvp\fR[]*/);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBexecve\fR(\fBconst char *\fR\fIpath\fR, \fBchar *const\fR \fIargv[]\fR,
-     \fBchar *const\fR \fIenvp[]\fR);
-.fi
-
-.LP
-.nf
-\fBint\fR \fBexeclp\fR(\fBconst char *\fR\fIfile\fR, \fBconst char *\fR\fIarg0\fR, \fB\&...
-     /* const char *\fR\fIargn\fR, \fB(char *)0 */);\fR
-.fi
-
-.LP
-.nf
-\fBint\fR \fBexecvp\fR(\fBconst char *\fR\fIfile\fR, \fBchar *const\fR \fIargv[]\fR);
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-Each of the functions in the \fBexec\fR family replaces the current process
-image with a new process image. The new image is constructed from a regular,
-executable file called the \fBnew process image file\fR. This file is either an
+.Dd Sep 19, 2014
+.Dt EXEC 2
+.Os
+.Sh NAME
+.Nm exec ,
+.Nm execl ,
+.Nm execle ,
+.Nm execlp ,
+.Nm execv ,
+.Nm execve ,
+.Nm execvp ,
+.Nm fexecve
+.Nd execute a file
+.Sh SYNOPSIS
+.In unistd.h
+.
+.Ft int
+.Fo execl
+.Fa "const char *path"
+.Fa "const char *arg0"
+.Fa "... /* const char *argn, (char *)0 */"
+.Fc
+.
+.Ft int
+.Fo execv
+.Fa "const char *path"
+.Fa "char *const argv[]"
+.Fc
+.
+.Ft int
+.Fo execle
+.Fa "const char *path"
+.Fa "const char *arg0"
+.Fa "... /* const char *argn, (char *)0, char *const envp[] */"
+.Fc
+.
+.Ft int
+.Fo execve
+.Fa "const char *path"
+.Fa "char *const argv[]"
+.Fa "char *const envp[]"
+.Fc
+.
+.Ft int
+.Fo execlp
+.Fa "const char *file"
+.Fa "const char *arg0"
+.Fa "... /* const char *argn, (char *)0 */"
+.Fc
+.
+.Ft int
+.Fo execvp
+.Fa "const char *file"
+.Fa "char *const argv[]"
+.Fc
+.
+.Ft int
+.Fo fexecve
+.Fa "int fd"
+.Fa "char *const argv[]"
+.Fa "char *const envp[]"
+.Fc
+.Sh DESCRIPTION
+Each of the functions in the
+.Nm exec
+family replaces the current process image with a new process image.
+The new image is constructed from a regular, executable file called the
+.Em new process image file .
+This file is either an
 executable object file or a file of data for an interpreter. There is no return
 from a successful call to one of these functions because the calling process
 image is overlaid by the new process image.
-.sp
-.LP
+.Lp
 An interpreter file begins with a line of the form
-.sp
-.in +2
-.nf
-#! pathname [\fIarg\fR]
-.fi
-.in -2
-
-.sp
-.LP
-where \fIpathname\fR is the path of the interpreter, and \fIarg\fR is an
-optional argument. When an interpreter file is executed, the system invokes the
-specified interpreter. The pathname specified in the interpreter file is passed
-as \fIarg0\fR to the interpreter. If \fIarg\fR was specified in the interpreter
-file, it is passed as \fIarg1\fR to the interpreter. The remaining arguments to
-the interpreter are \fIarg0\fR through \fIargn\fR of the originally exec'd
-file. The interpreter named by \fIpathname\fR must not be an interpreter file.
-.sp
-.LP
+.Lp
+.Dl #! pathname Op Ar arg
+.Lp
+where
+.Ar pathname
+is the path of the interpreter, and
+.Ar arg
+is an optional argument.
+When an interpreter file is executed, the system invokes the
+specified interpreter.
+The pathname specified in the interpreter file is passed as
+.Fa arg0
+to the interpreter.
+If
+.Ar arg
+was specified in the interpreter file, it is passed as
+.Fa arg1
+to the interpreter.
+The remaining arguments to
+the interpreter are
+.Fa arg0
+through
+.Fa argn
+of the originally exec'd file.
+The interpreter named by
+.Ar pathname
+must not be an interpreter file.
+.Lp
 When a C-language program is executed as a result of this call, it is entered
 as a C-language function call as follows:
-.sp
-.in +2
-.nf
-int main (int argc, char *argv[]);
-.fi
-.in -2
-
-.sp
-.LP
-where \fIargc\fR is the argument count and \fIargv\fR is an array of character
-pointers to the arguments themselves. In addition, the following variable:
-.sp
-.in +2
-.nf
-extern char **environ;
-.fi
-.in -2
-
-.sp
-.LP
+.Lp
+.Dl Ft int Fn main "int argc" "char *argv[]"
+.Lp
+where
+.Fa argc
+is the argument count and
+.Fa argv
+is an array of character pointers to the arguments themselves.
+In addition, the following variable:
+.Lp
+.Dl Vt "extern char **" Ns Va environ ;
+.Lp
 is initialized as a pointer to an array of character pointers to the
-environment strings. The \fIargv\fR and \fIenviron\fR arrays are each
-terminated by a null pointer. The null pointer terminating the \fIargv\fR array
-is not counted in \fIargc\fR.
-.sp
-.LP
-The value of \fIargc\fR is non-negative, and if greater than 0, \fIargv\fR[0]
-points to a string containing the name of the file. If \fIargc\fR is 0,
-\fIargv\fR[0] is a null pointer, in which case there are no arguments.
-Applications should verify that \fIargc\fR is greater than 0 or that
-\fIargv\fR[0] is not a null pointer before dereferencing \fIargv\fR[0].
-.sp
-.LP
-The arguments specified by a program with one of the \fBexec\fR functions are
-passed on to the new process image in the \fBmain()\fR arguments.
-.sp
-.LP
-The \fIpath\fR argument points to a path name that identifies the new process
-image file.
-.sp
-.LP
-The \fIfile\fR argument is used to construct a pathname that identifies the new
-process image file. If the \fIfile\fR argument contains a slash character, it
-is used as the pathname for this file. Otherwise, the path prefix for this file
-is obtained by a search of the directories passed in the \fBPATH\fR environment
-variable (see \fBenviron\fR(5)). The environment is supplied typically by the
-shell. If the process image file is not a valid executable object file,
-\fBexeclp()\fR and \fBexecvp()\fR use the contents of that file as standard
-input to the shell. In this case, the shell becomes the new process image. The
-standard to which the caller conforms determines which shell is used. See
-\fBstandards\fR(5).
-.sp
-.LP
-The arguments represented by \fIarg0\fR\&.\|.\|. are pointers to
-null-terminated character strings. These strings constitute the argument list
-available to the new process image. The list is terminated by a null pointer.
-The \fIarg0\fR argument should point to a filename that is associated with the
-process being started by one of the \fBexec\fR functions.
-.sp
-.LP
-The \fIargv\fR argument is an array of character pointers to null-terminated
-strings. The last member of this array must be a null pointer. These strings
-constitute the argument list available to the new process image. The value in
-\fIargv\fR[0] should point to a filename that is associated with the process
-being started by one of the \fBexec\fR functions.
-.sp
-.LP
-The \fIenvp\fR argument is an array of character pointers to null-terminated
-strings. These strings constitute the environment for the new process image.
-The \fIenvp\fR array is terminated by a null pointer. For \fBexecl()\fR,
-\fBexecv()\fR, \fBexecvp()\fR, and \fBexeclp()\fR, the C-language run-time
+environment strings.
+The
+.Fa argv
+and
+.Va environ
+arrays are each terminated by a null pointer.
+The null pointer terminating the
+.Fa argv
+array is not counted in
+.Fa argc .
+.Lp
+The value of
+.Fa argc
+is non-negative, and if greater than 0,
+.Fa argv Ns [0]
+points to a string containing the name of the file.
+If
+.Fa argc
+is 0,
+.Fa argv Ns [0]
+is a null pointer, in which case there are no arguments.
+Applications should verify that
+.Fa argc
+is greater than 0 or that
+.Fa argv Ns [0]
+is not a null pointer before dereferencing
+.Fa argv Ns [0] .
+.Lp
+The arguments specified by a program with one of the
+.Nm exec
+functions are passed on to the new process image in the
+Fn main
+arguments.
+.Lp
+The
+.Fa path
+argument points to a path name that identifies the new process image file.
+.Lp
+The
+.Fa file
+argument is used to construct a pathname that identifies the new
+process image file.
+If the
+.Fa file
+argument contains a slash character, it is used as the pathname for this file.
+Otherwise, the path prefix for this file is obtained by a search of the
+directories passed in the
+.Ev PATH
+environment variable.
+See
+.Xr environ 5 .
+The environment is supplied typically by the shell.
+If the process image file is not a valid executable object file,
+.Fn execlp
+and
+.Fn execvp
+use the contents of that file as standard input to the shell.
+In this case, the shell becomes the new process image.
+The standard to which the caller conforms determines which shell is used.
+See
+.Xr standards 5 .
+.Lp
+The
+.Fn fexecve
+function is equivalent to
+.Fn execve ,
+except that instead of using a named file, the file referenced by
+the file descriptor
+.Fa fd
+is used.  Note that this file descriptor must reference a regular
+file and must have been opened for execute
+.Po with
+Dv O_EXEC ,
+defined in
+.In fcntl.h .
+.Pc
+The image is loaded from offset zero of the file, regardless of
+the offset of
+.Fa fd .
+.Lp
+The arguments represented by
+.Fa arg0 Ns  "..."
+are pointers to null-terminated character strings.
+These strings constitute the argument list available to the new process image.
+The list is terminated by a null pointer.
+The
+.Fa arg0
+argument should point to a filename that is associated with the
+process being started by one of the
+.Nm exec
+functions.
+.Lp
+The
+.Fa argv
+argument is an array of character pointers to null-terminated strings.
+The last member of this array must be a null pointer.
+These strings constitute the argument list available to the new process image.
+The value in
+.Fa argv Ns [0]
+should point to a filename that is associated with the process
+being started by one of the
+.Nm exec
+functions.
+.Lp
+The
+.Fa envp
+argument is an array of character pointers to null-terminated strings.
+These strings constitute the environment for the new process image.
+The
+.Fa envp
+array is terminated by a null pointer.
+For
+.Fn execl , execv , execvp ,
+and
+.Fn execlp ,
+the C-language run-time
 start-off routine places a pointer to the environment of the calling process in
-the global object \fBextern char **environ\fR, and it is used to pass the
+the global object
+.Va environ ,
+and it is used to pass the
 environment of the calling process to the new process image.
-.sp
-.LP
+.Lp
 The number of bytes available for the new process's combined argument and
-environment lists is \fBARG_MAX\fR. It is implementation-dependent whether null
+environment lists is
+.Dv ARG_MAX .
+It is implementation-dependent whether null
 terminators, pointers, and/or any alignment bytes are included in this total.
-.sp
-.LP
+.Lp
 File descriptors open in the calling process image remain open in the new
-process image, except for those whose close-on-exec flag \fBFD_CLOEXEC\fR is
-set; see \fBfcntl\fR(2). For those file descriptors that remain open, all
+process image, except for those whose close-on-exec flag
+.Dv FD_CLOEXEC
+is set; see
+.Xr fcntl 2 .
+For those file descriptors that remain open, all
 attributes of the open file description, including file locks, remain
 unchanged.
-.sp
-.LP
-The preferred hardware address translation size (see \fBmemcntl\fR(2)) for the
+.Lp
+The preferred hardware address translation size
+.Pq see Xr memcntl 2
+for the
 stack and heap of the new process image are set to the default system page
 size.
-.sp
-.LP
+.Lp
 Directory streams open in the calling process image are closed in the new
 process image.
-.sp
-.LP
+.Lp
 The state of conversion descriptors and message catalogue descriptors in the
 new process image is undefined. For the new process, the equivalent of:
-.sp
-.in +2
-.nf
-setlocale(LC_ALL, "C")
-.fi
-.in -2
-
-.sp
-.LP
+.Lp
+.Dl Fn setlocale LC_ALL \("C" ;
+.Lp
 is executed at startup.
-.sp
-.LP
-Signals set to the default action (\fBSIG_DFL\fR) in the calling process image
-are set to the default action in the new process image (see \fBsignal\fR(3C)).
-Signals set to be ignored (\fBSIG_IGN\fR) by the calling process image are set
-to be ignored by the new process image. Signals set to be caught by the calling
-process image are set to the default action in the new process image (see
-\fBsignal.h\fR(3HEAD)). After a successful call to any of the \fBexec\fR
-functions, alternate signal stacks are not preserved and the \fBSA_ONSTACK\fR
+.Lp
+Signals set to the default action
+.Pq Dv BSIG_DFL
+in the calling process image
+are set to the default action in the new process image
+.Pq see Xr signal 3C .
+Signals set to be ignored
+.Pq Dv SIG_IGN
+by the calling process image are set to be ignored by the new process image.
+Signals set to be caught by the calling
+process image are set to the default action in the new process image
+.Pq see Xr signal.h 3HEAD .
+After a successful call to any of the
+.Nm exec
+functions, alternate signal stacks are not preserved and the
+.Dv SA_ONSTACK
 flag is cleared for all signals.
-.sp
-.LP
-After a successful call to any of the \fBexec\fR functions, any functions
-previously registered by \fBatexit\fR(3C) are no longer registered.
-.sp
-.LP
+.Lp
+After a successful call to any of the
+.Nm exec
+functions, any functions
+previously registered by
+.Xr atexit 3C
+are no longer registered.
+.Lp
 The saved resource limits in the new process image are set to be a copy of the
 process's corresponding hard and soft resource limits.
-.sp
-.LP
-If the \fBST_NOSUID\fR bit is set for the file system containing the new
-process image file, then the effective user \fBID\fR and effective group
-\fBID\fR are unchanged in the new process image. If the set-user-\fBID\fR mode
-bit of the new process image file is set (see \fBchmod\fR(2)), the effective
-user \fBID\fR of the new process image is set to the owner \fBID\fR of the new
-process image file. Similarly, if the set-group-\fBID\fR mode bit of the new
-process image file is set, the effective group \fBID\fR of the new process
-image is set to the group \fBID\fR of the new process image file. The real user
-\fBID\fR and real group \fBID\fR of the new process image remain the same as
-those of the calling process image. The effective user ID and effective group
-ID of the new process image are saved (as the saved set-user-ID and the saved
-set-group-ID for use by \fBsetuid\fR(2).
-.sp
-.LP
+.Lp
+If the
+.Dv ST_NOSUID
+bit is set for the file system containing the new
+process image file, then the effective user ID and effective group
+ID are unchanged in the new process image.
+If the set-user-ID mode bit of the new process image file is set
+.Pq see Xr chmod 2 ,
+the effective
+user ID of the new process image is set to the owner ID of the new
+process image file.
+Similarly, if the set-group-ID mode bit of the new
+process image file is set, the effective group ID of the new process
+image is set to the group ID of the new process image file.
+The real user ID and real group ID of the new process image remain the same as
+those of the calling process image.
+The effective user ID and effective group
+ID of the new process image are saved
+.Po
+as the saved set-user-ID and the saved set-group-ID for use by
+.Xr setuid 2 Pc .
+.Lp
 The privilege sets are changed according to the following rules:
-.RS +4
-.TP
-1.
+.Bl -enum
+.It
 The inheritable set, I, is intersected with the limit set, L.  This
 mechanism enforces the limit set for processes.
-.RE
-.RS +4
-.TP
-2.
+.It
 The effective set, E, and the permitted set, P, are made equal to the new
 inheritable set.
-.RE
-.sp
-.LP
+.El
+.Lp
 The system attempts to set the privilege-aware state to non-PA both before
 performing any modifications to the process IDs and privilege sets as well as
 after completing the transition to new UIDs and privilege sets, following the
-rules outlined in \fBprivileges\fR(5).
-.sp
-.LP
-If the {\fBPRIV_PROC_OWNER\fR} privilege is asserted in the effective set, the
+rules outlined in
+.Xr privileges 5 .
+.Lp
+If the
+.Brq Dv PRIV_PROC_OWNER
+privilege is asserted in the effective set, the
 set-user-ID and set-group-ID bits will be honored when the process is being
-controlled by \fBptrace\fR(3C). Additional restriction can apply when the
-traced process has an effective UID of 0. See \fBprivileges\fR(5).
-.sp
-.LP
+controlled by
+.Xr ptrace 3C .
+Additional restrictions can apply when the
+traced process has an effective UID of 0.
+See
+.Xr privileges 5 .
+.Lp
 Any shared memory segments attached to the calling process image will not be
-attached to the new process image (see \fBshmop\fR(2)). Any mappings
-established through \fBmmap()\fR are not preserved across an \fBexec\fR. Memory
+attached to the new process image
+.Pq see Xr shmop 2 .
+Any mappings
+established through
+.Xr mmap 2
+are not preserved across an
+.Nm exec .
+Memory
 mappings created in the process are unmapped before the address space is
-rebuilt for the new process image. See \fBmmap\fR(2).
-.sp
-.LP
-Memory locks established by the calling process via calls to \fBmlockall\fR(3C)
-or \fBmlock\fR(3C) are removed. If locked pages in the address space of the
+rebuilt for the new process image.
+See
+.Xr mmap 2 .
+.Lp
+Memory locks established by the calling process via calls to
+.Xr mlockall 3C
+or
+.Xr mlock 3C
+are removed.
+If locked pages in the address space of the
 calling process are also mapped into the address spaces the locks established
 by the other processes will be unaffected by the call by this process to the
-\fBexec\fR function. If the \fBexec\fR function fails, the effect on memory
-locks is unspecified.
-.sp
-.LP
-If \fB_XOPEN_REALTIME\fR is defined and has a value other than \(mi1, any named
+.Nm exec
+function.
+If the
+.Nm exec
+function fails, the effect on memory locks is unspecified.
+.Lp
+If
+.Dv _XOPEN_REALTIME
+is defined and has a value other than \(mi1, any named
 semaphores open in the calling process are closed as if by appropriate calls to
-\fBsem_close\fR(3C)
-.sp
-.LP
-Profiling is disabled for the new process; see \fBprofil\fR(2).
-.sp
-.LP
-Timers created by the calling process with \fBtimer_create\fR(3C) are deleted
+.Xr sem_close 3C .
+.Lp
+Profiling is disabled for the new process; see
+.Xr profil 2 .
+.Lp
+Timers created by the calling process with
+.Xr timer_create 3C
+are deleted
 before replacing the current process image with the new process image.
-.sp
-.LP
-For the \fBSCHED_FIFO\fR and \fBSCHED_RR\fR scheduling policies, the policy and
-priority settings are not changed by a call to an \fBexec\fR function.
-.sp
-.LP
+.Lp
+For the
+.Dv SCHED_FIFO
+and
+.Dv SCHED_RR
+scheduling policies, the policy and
+priority settings are not changed by a call to an
+.Nm exec
+function.
+.Lp
 All open message queue descriptors in the calling process are closed, as
-described in \fBmq_close\fR(3C).
-.sp
-.LP
+described in
+.Xr mq_close 3C .
+.Lp
 Any outstanding asynchronous I/O operations may be cancelled. Those
 asynchronous I/O operations that are not canceled will complete as if the
-\fBexec\fR function had not yet occurred, but any associated signal
-notifications are suppressed. It is unspecified whether the \fBexec\fR function
-itself blocks awaiting such I/O completion. In no event, however, will the new
-process image created by the \fBexec\fR function be affected by the presence of
-outstanding asynchronous I/O operations at the time the \fBexec\fR function is
-called.
-.sp
-.LP
-All active contract templates are cleared (see \fBcontract\fR(4)).
-.sp
-.LP
+.Nm exec
+function had not yet occurred, but any associated signal
+notifications are suppressed.
+It is unspecified whether the
+.Nm exec
+function itself blocks awaiting such I/O completion.
+In no event, however, will the new process image created by the
+.Nm exec
+function be affected by the presence of
+outstanding asynchronous I/O operations at the time the
+.Nm exec
+function is called.
+.Lp
+All active contract templates are cleared
+.Pq see Xr contract 4 .
+.Lp
 The new process also inherits the following attributes from the calling
 process:
-.RS +4
-.TP
-.ie t \(bu
-.el o
+.Bl -bullet -offset indent
+.It
 controlling terminal
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
+.It
 current working directory
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-file-locks (see \fBfcntl\fR(2) and \fBlockf\fR(3C))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-file mode creation mask (see \fBumask\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-file size limit (see \fBulimit\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
+.It
+file-locks
+.Po see
+.Xr fcntl 2
+and
+.Xr lockf 3C
+.Pc
+.It
+file mode creation mask
+.Pq see Xr umask 2
+.It
+file size limit
+.Pq see Xr ulimit 2
+.It
 limit privilege set
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-nice value (see \fBnice\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-parent process \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-pending signals (see \fBsigpending\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-privilege debugging flag (see \fBprivileges\fR(5) and \fBgetpflags\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-process \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-process contract (see \fBcontract\fR(4) and \fBprocess\fR(4))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-process group \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-process signal mask (see \fBsigprocmask\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-processor bindings (see \fBprocessor_bind\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-processor set bindings (see \fBpset_bind\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-project \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-real group \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-real user \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-resource limits (see \fBgetrlimit\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
+.It
+nice value
+.Pq see Xr nice 2
+.It
+parent process ID
+.It
+pending signals
+.Pq see Xr sigpending 2
+.It
+privilege debugging flag
+.Po see Xr privileges 5
+and
+.Xr getpflags 2
+.Pc
+.It
+process ID
+.It
+process contract
+.Po see Xr contract 4
+and
+.Xr process 4
+.Pc
+.It
+process group ID
+.It
+process signal mask
+.Pq see Xr sigprocmask 2
+.It
+processor bindings
+.Pq see Xr processor_bind 2
+.It
+processor set bindings
+.Pq see Xr pset_bind 2
+.It
+project ID
+.It
+real group ID
+.It
+real user ID
+.It
+resource limits
+.Pq see Xr getrlimit 2
+.It
 root directory
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-scheduler class and priority (see \fBpriocntl\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-\fBsemadj\fR values (see \fBsemop\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-session membership (see \fBexit\fR(2) and \fBsignal\fR(3C))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-supplementary group \fBIDs\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-task \fBID\fR
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-time left until an alarm clock signal (see \fBalarm\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-\fBtms_utime\fR, \fBtms_stime\fR, \fBtms_cutime\fR, and \fBtms_cstime\fR (see
-\fBtimes\fR(2))
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-trace flag (see \fBptrace\fR(3C) request 0)
-.RE
-.sp
-.LP
-A call to any \fBexec\fR function from a process with more than one thread
+.It
+scheduler class and priority
+.Pq see Xr priocntl 2
+.It
+.Sy semadj
+values
+.Pq see Xr semop 2
+.It
+session membership
+.Po see
+.Xr exit 2
+and
+.Xr signal 3C
+.Pc
+.It
+supplementary group IDs
+.It
+task ID
+.It
+time left until an alarm clock signal
+.Pq see Xr alarm 2
+.It
+.Sy tms_utime , tms_stime , tms_cutime ,
+and
+.Sy tms_cstime
+.Pq see Xr times 2
+.It
+trace flag
+.Po see Xr ptrace 3C
+request 0
+.Pc
+.El
+.Lp
+A call to any
+.Nm exec
+function from a process with more than one thread
 results in all threads being terminated and the new executable image being
-loaded and executed. No destructor functions will be called.
-.sp
-.LP
-Upon successful completion, each of the functions in the \fBexec\fR family
-marks for update the \fBst_atime\fR field of the file.  If an \fBexec\fR
-function failed but was able to locate the \fBprocess image file\fR, whether
-the \fBst_atime\fR field is marked for update is unspecified. Should the
-function succeed, the process image file is considered to have been opened with
-\fBopen\fR(2). The corresponding \fBclose\fR(2) is considered to occur at a
+loaded and executed.
+No destructor functions will be called.
+.Lp
+Upon successful completion, each of the functions in the
+.Nm exec
+family marks for update the
+.Va st_atime
+field of the file.
+If an
+.Nm exec
+function failed but was able to locate the
+.Em process image file ,
+whether
+the
+.Va st_atime
+field is marked for update is unspecified.
+Should the function succeed, the process image file is considered to have
+been opened with
+.Xr open 2 .
+The corresponding
+.Xr close 2
+is considered to occur at a
 time after this open, but before process termination or successful completion
-of a subsequent call to one of the \fBexec\fR functions. The \fIargv\fR[\|] and
-\fIenvp\fR[\|] arrays of pointers and the strings to which those arrays point
-will not be modified by a call to one of the \fBexec\fR functions, except as a
-consequence of replacing the process image.
-.sp
-.LP
+of a subsequent call to one of the
+.Nm exec
+functions.
+The
+.Fa argv
+and
+.Fa envp
+arrays of pointers and the strings to which those arrays point
+will not be modified by a call to one of the
+.Nm exec
+functions, except as a consequence of replacing the process image.
+.Lp
 The saved resource limits in the new process image are set to be a copy of the
 process's corresponding hard and soft limits.
-.SH RETURN VALUES
-.sp
-.LP
-If a function in the \fBexec\fR family returns to the calling process image, an
-error has occurred; the return value is \fB\(mi1\fR and \fBerrno\fR is set to
-indicate the error.
-.SH ERRORS
-.sp
-.LP
-The \fBexec\fR functions will fail if:
-.sp
-.ne 2
-.na
-\fB\fBE2BIG\fR\fR
-.ad
-.RS 16n
+.
+.Sh RETURN VALUES
+.
+If a function in the
+.Nm exec
+family returns to the calling process image, an
+error has occurred; the return value is \fB\(mi1\fR and
+.Va errno
+is set to indicate the error.
+.
+.Sh ERRORS
+.
+The
+.Nm exec
+functions will fail if:
+.Bl -tag -width Er
+.It Bq Er E2BIG
 The number of bytes in the new process's argument list is greater than the
-system-imposed limit of {\fBARG_MAX\fR} bytes. The argument list limit is sum
+system-imposed limit of
+.Brq Dv ARG_MAX
+bytes.
+The argument list limit is sum
 of the size of the argument list plus the size of the environment's exported
 shell variables.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEACCES\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er EACCES
 Search permission is denied for a directory listed in the new process file's
 path prefix.
 .sp
@@ -533,202 +600,225 @@
 .sp
 The new process file mode denies execute permission.
 .sp
-The {\fBFILE_DAC_SEARCH\fR} privilege overrides the restriction on directory
-searches.
+The
+.Brq Dv FILE_DAC_SEARCH
+privilege overrides the restriction on directory searches.
 .sp
-The {\fBFILE_DAC_EXECUTE\fR} privilege overrides the lack of execute
+The
+.Brq Dv FILE_DAC_EXECUTE
+privilege overrides the lack of execute
 permission.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEAGAIN\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er EAGAIN
 Total amount of system memory available when reading using raw I/O is
 temporarily insufficient.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEFAULT\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er EFAULT
 An argument points to an illegal address.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEINVAL\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er EINVAL
 The new process image file has the appropriate permission and has a recognized
 executable binary format, but the system does not support execution of a file
 with this format.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBEINTR\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er EINTR
 A signal was caught during the execution of one of the functions in the
-\fIexec\fR family.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBELOOP\fR\fR
-.ad
-.RS 16n
-Too many symbolic links were encountered in translating \fIpath\fR or
-\fIfile\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENAMETOOLONG\fR\fR
-.ad
-.RS 16n
-The length of the \fIfile\fR or \fIpath\fR argument exceeds {\fBPATH_MAX\fR},
-or the length of a \fIfile\fR or \fIpath\fR component exceeds {\fBNAME_MAX\fR}
-while {\fB_POSIX_NO_TRUNC\fR} is in effect.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOENT\fR\fR
-.ad
-.RS 16n
+.Nm exec
+family.
+.El
+.
+.Lp
+The
+.Nm exec
+functions except
+.Fn fexecve
+will fail if:
+.
+.Bl -tag -width Er
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating
+.Fa path
+or
+.Fa file .
+.
+.It Bq Er ENAMETOOLONG
+The length of the
+.Fa file
+or
+.Fa path
+argument exceeds
+.Brq PATH_MAX ,
+or the length of a
+.Fa file
+or
+.Fa path
+component exceeds
+.Brq Dv NAME_MAX
+while
+.Brq Dv _POSIX_NO_TRUNC
+is in effect.
+.
+.It Bq Er ENOENT
 One or more components of the new process path name of the file do not exist or
 is a null pathname.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOLINK\fR\fR
-.ad
-.RS 16n
-The \fIpath\fR argument points to a remote machine and the link to that machine
+.
+.It Bq Er ENOLINK
+The
+.Fa path
+argument points to a remote machine and the link to that machine
 is no longer active.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOTDIR\fR\fR
-.ad
-.RS 16n
+.
+.It Bq Er ENOTDIR
 A component of the new process path of the file prefix is not a directory.
-.RE
-
-.sp
-.LP
-The \fBexec\fR functions, except for \fBexeclp()\fR and \fBexecvp()\fR, will
-fail if:
-.sp
-.ne 2
-.na
-\fB\fBENOEXEC\fR\fR
-.ad
-.RS 11n
+.El
+.Lp
+The
+.Nm exec
+functions, except for
+.Fn execlp
+and
+.Fn execvp ,
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOEXEC
 The new process image file has the appropriate access permission but is not in
 the proper format.
-.RE
-
+.El
+.Lp
+The
+.Fn fexecve
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid file descriptor opened for execute.
+.El
 .sp
-.LP
-The \fBexec\fR functions may fail if:
-.sp
-.ne 2
-.na
-\fB\fBENAMETOOLONG\fR\fR
-.ad
-.RS 16n
+.Lp
+The
+.Nm exec
+functions except for
+.Fn fexecve
+may fail if:
+.
+.Bl -tag -width Er
+.It Bq Er ENAMETOOLONG
 Pathname resolution of a symbolic link produced an intermediate result whose
-length exceeds {\fBPATH_MAX\fR}.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBENOMEM\fR\fR
-.ad
-.RS 16n
+length exceeds
+.Brq Dv PATH_MAX .
+.
+.It Bq Er ENOMEM
 The new process image requires more memory than is allowed by the hardware or
-system-imposed by memory management constraints. See \fBbrk\fR(2).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBETXTBSY\fR\fR
-.ad
-.RS 16n
+system-imposed by memory management constraints.
+See
+.Xr brk 2 .
+.
+.It Bq Er ETXTBSY
 The new process image file is a pure procedure (shared text) file that is
 currently open for writing by some process.
-.RE
-
-.SH USAGE
-.sp
-.LP
+.El
+.
+.Sh USAGE
+.
 As the state of conversion descriptors and message catalogue descriptors in the
 new process image is undefined, portable applications should not rely on their
-use and should close them prior to calling one of the \fBexec\fR functions.
-.sp
-.LP
+use and should close them prior to calling one of the
+.Nm exec
+functions.
+.Lp
 Applications that require other than the default POSIX locale should call
-\fBsetlocale\fR(3C) with the appropriate parameters to establish the locale of
-thenew process.
-.sp
-.LP
-The \fIenviron\fR array should not be accessed directly by the application.
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE	ATTRIBUTE VALUE
-_
-Interface Stability	Committed
-_
-MT-Level	See below.
-_
-Standard	See \fBstandards\fR(5).
-.TE
-
-.sp
-.LP
-The \fBexecle()\fR and \fBexecve()\fR fucntions are Async-Signal-Safe.
-.SH SEE ALSO
-.sp
-.LP
-\fBksh\fR(1), \fBps\fR(1), \fBsh\fR(1), \fBalarm\fR(2), \fBbrk\fR(2),
-\fBchmod\fR(2), \fBexit\fR(2), \fBfcntl\fR(2), \fBfork\fR(2),
-\fBgetpflags\fR(2), \fBgetrlimit\fR(2), \fBmemcntl\fR(2), \fBmmap\fR(2),
-\fBnice\fR(2), \fBpriocntl\fR(2), \fBprofil\fR(2), \fBsemop\fR(2),
-\fBshmop\fR(2), \fBsigpending\fR(2), \fBsigprocmask\fR(2), \fBtimes\fR(2),
-\fBumask\fR(2), \fBlockf\fR(3C), \fBptrace\fR(3C), \fBsetlocale\fR(3C),
-\fBsignal\fR(3C), \fBsystem\fR(3C), \fBtimer_create\fR(3C), \fBa.out\fR(4),
-\fBcontract\fR(4), \fBprocess\fR(4), \fBattributes\fR(5), \fBenviron\fR(5),
-\fBprivileges\fR(5), \fBstandards\fR(5)
-.SH WARNINGS
-.sp
-.LP
-If a program is \fBsetuid\fR to a user \fBID\fR other than the superuser, and
-the program is executed when the real user \fBID\fR is super-user, then the
+.Xr setlocale 3C
+with the appropriate parameters to establish the locale of the new process.
+.Lp
+The
+.Va environ
+array should not be accessed directly by the application.
+Instead,
+.Xr getenv 3C
+should be used.
+.
+.Sh SEE ALSO
+.Xr ps 1 ,
+.Xr sh 1 ,
+.Xr alarm 2 ,
+.Xr brk 2 ,
+.Xr chmod 2 ,
+.Xr exit 2 ,
+.Xr fcntl 2 ,
+.Xr fork 2 ,
+.Xr getpflags 2 ,
+.Xr getrlimit 2 ,
+.Xr memcntl 2 ,
+.Xr mmap 2 ,
+.Xr nice 2 ,
+.Xr open 2 ,
+.Xr priocntl 2 ,
+.Xr profil 2 ,
+.Xr semop 2 ,
+.Xr shmop 2 ,
+.Xr sigpending 2 ,
+.Xr sigprocmask 2 ,
+.Xr times 2 ,
+.Xr umask 2 ,
+.Xr lockf 3C ,
+.Xr ptrace 3C ,
+.Xr setlocale 3C ,
+.Xr signal 3C ,
+.Xr system 3C ,
+.Xr timer_create 3C ,
+.Xr fcntl.h 3HEAD ,
+.Xr signal.h 3HEAD ,
+.Xr unistd.h 3HEAD ,
+.Xr a.out 4 ,
+.Xr contract 4 ,
+.Xr process 4 ,
+.Xr environ 5 ,
+.Xr privileges 5 ,
+.Xr standards 5
+.
+.Sh INTERFACE STABILITY
+.
+.Sy Standard .
+.
+.Sh MT-LEVEL
+.
+The
+.Fn execle , execve , fexecve
+functions are
+.Sy Async-Signal-Safe .
+.
+.Sh STANDARDS
+.
+These functions are available in the following compilation environments.
+See
+.Xr standards 5 .
+.Ss Fn execl , execle , execlp , execv , execve , execvp
+.Bl -bullet -compact
+.It
+.St -p1003.1-90
+.It
+.St -xpg3
+.It
+.St -xpg4
+.It
+.St -xpg4.2
+.It
+.St -susv2
+.It
+.St -susv3
+.It
+.St -p1003.1-2008
+.El
+.Ss Fn fexecve
+.Bl -bullet -compact
+.It
+.St -p1003.1-2008
+.El
+.
+.Sh WARNINGS
+If a program is
+.Em setuid
+to a user ID other than the superuser, and
+the program is executed when the real user ID is super-user, then the
 program has some of the powers of a super-user as well.
--- old/usr/src/pkg/manifests/system-kernel.man2.inc	Mon Apr  6 11:47:36 2015
+++ new/usr/src/pkg/manifests/system-kernel.man2.inc	Mon Apr  6 11:47:36 2015
@@ -13,6 +13,7 @@
 # Copyright 2011, Richard Lowe
 # Copyright 2012 Nexenta Systems, Inc. All rights reserved.
 # Copyright 2013, OmniTI Computer Consulting, Inc.
+# Copyright 2015 Garrett D'Amore <garrett@damore.org>
 #
 
 file path=usr/share/man/man2/Intro.2
@@ -182,6 +183,7 @@
 link path=usr/share/man/man2/fchown.2 target=chown.2
 link path=usr/share/man/man2/fchownat.2 target=chown.2
 link path=usr/share/man/man2/fchroot.2 target=chroot.2
+link path=usr/share/man/man2/fexecve.2 target=exec.2
 link path=usr/share/man/man2/fgetlabel.2 target=getlabel.2
 link path=usr/share/man/man2/fork1.2 target=fork.2
 link path=usr/share/man/man2/forkall.2 target=fork.2
--- old/usr/src/pkg/manifests/system-test-libctest.mf	Mon Apr  6 11:47:36 2015
+++ new/usr/src/pkg/manifests/system-test-libctest.mf	Mon Apr  6 11:47:36 2015
@@ -53,6 +53,9 @@
 file path=opt/libc-tests/cfg/symbols/wchar_h.cfg mode=0444
 file path=opt/libc-tests/cfg/symbols/wctype_h.cfg mode=0444
 file path=opt/libc-tests/runfiles/default.run mode=0444
+file path=opt/libc-tests/tests/fexecve_test mode=0555
+file path=opt/libc-tests/tests/fexecve_test.$(ARCH) mode=0555
+file path=opt/libc-tests/tests/fexecve_test.$(ARCH64) mode=0555
 file path=opt/libc-tests/tests/fpround_test mode=0555
 file path=opt/libc-tests/tests/fpround_test.$(ARCH) mode=0555
 file path=opt/libc-tests/tests/fpround_test.$(ARCH64) mode=0555
--- old/usr/src/test/libc-tests/cfg/symbols/unistd_h.cfg	Mon Apr  6 11:47:36 2015
+++ new/usr/src/test/libc-tests/cfg/symbols/unistd_h.cfg	Mon Apr  6 11:47:36 2015
@@ -91,6 +91,11 @@
 	int; uid_t; gid_t					|\
 	unistd.h | -POSIX+ SUS+
 
+func |	fexecve							|\
+	int							|\
+	int; char *const []; char *const []			|\
+	unistd.h | -ALL SUSv4+
+
 func |	getlogin						|\
 	char *							|\
 	void							|\
--- old/usr/src/test/libc-tests/runfiles/default.run	Mon Apr  6 11:47:37 2015
+++ new/usr/src/test/libc-tests/runfiles/default.run	Mon Apr  6 11:47:37 2015
@@ -11,7 +11,7 @@
 
 #
 # Copyright (c) 2012 by Delphix. All rights reserved.
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2015 Garrett D'Amore <garrett@damore.org>
 #
 
 [DEFAULT]
@@ -22,6 +22,8 @@
 post =
 outputdir = /var/tmp/test_results
 
+[/opt/libc-tests/tests/fexecve_test]
+
 [/opt/libc-tests/tests/fpround_test]
 
 [/opt/libc-tests/tests/newlocale_test]
--- old/usr/src/test/libc-tests/tests/Makefile	Mon Apr  6 11:47:38 2015
+++ new/usr/src/test/libc-tests/tests/Makefile	Mon Apr  6 11:47:38 2015
@@ -14,7 +14,7 @@
 # Copyright 2015 Garrett D'Amore <garrett@damore.org>
 #
 
-SUBDIRS = fpround newlocale nl_langinfo symbols wcsrtombs wctype
+SUBDIRS = fexecve fpround newlocale nl_langinfo symbols wcsrtombs wctype
 
 include $(SRC)/Makefile.master
 include $(SRC)/test/Makefile.com
--- /dev/null	Mon Apr  6 11:47:38 2015
+++ new/usr/src/test/libc-tests/tests/fexecve/Makefile	Mon Apr  6 11:47:38 2015
@@ -0,0 +1,21 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+include $(SRC)/Makefile.master
+
+PROG = fexecve_test
+ARCHPROG = fexecve_test
+
+include ../Makefile.com
--- /dev/null	Mon Apr  6 11:47:39 2015
+++ new/usr/src/test/libc-tests/tests/fexecve/fexecve_test.c	Mon Apr  6 11:47:39 2015
@@ -0,0 +1,245 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2015 Garrett D'Amore <garrett@damore.org>
+ */
+
+/*
+ * This program tests that fexecve works properly.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <err.h>
+#include <errno.h>
+#include <unistd.h>
+#include <note.h>
+#include <sys/utsname.h>
+#include <sys/wait.h>
+#include "test_common.h"
+
+int extra_debug = 0;
+
+struct utsname un;
+
+void
+forkit(char *msg, const char *expect, void (*postfn)(void))
+{
+	int fd;
+	FILE *f;
+	pid_t pid;
+	char *ptr = NULL;
+	size_t cap = 0;
+	int wstat;
+	int rv;
+	test_t t;
+	char fname[32];
+
+	(void) strcpy(fname, "/tmp/testXXXXXX");
+	t = test_start(msg);
+
+	fd = mkstemp(fname);
+	if (fd < 0) {
+		test_failed(t, "mkstemp failed: %s", strerror(errno));
+		return;
+	}
+
+	/* don't leave it in the filesystem */
+	(void) unlink(fname);
+
+	pid = vfork();
+	switch (pid) {
+	case -1:
+		test_failed(t, "vfork failed: %s", strerror(errno));
+		return;
+	case 0:
+		if (dup2(fd, 1) < 0) {
+			test_failed(t, "dup2 failed: %s", strerror(errno));
+			exit(9);
+		}
+		postfn();
+		exit(0);
+	default:
+		break;
+	}
+
+	/* parent */
+	f = fdopen(fd, "r");
+	if (f == NULL) {
+		(void) close(fd);
+		test_failed(t, "fdopen failed: %s", strerror(errno));
+		(void) wait(NULL);
+		return;
+	}
+	if (waitpid(pid, &wstat, NULL) < 0) {
+		test_failed(t, "wait failed: %s", strerror(errno));
+		(void) fclose(f);
+		return;
+	}
+	if (!WIFEXITED(wstat) || WEXITSTATUS(wstat) != 0) {
+		test_failed(t, "child failed: %#x", wstat);
+		(void) fclose(f);
+		return;
+	}
+	(void) lseek(fd, 0, SEEK_SET);
+	if ((rv = getline(&ptr, &cap, f)) < 1) {
+		test_failed(t, "child gave no data: %d", rv);
+		(void) fclose(f);
+		return;
+	}
+	(void) fclose(f);
+
+	if (strncmp(ptr, expect, strlen(expect)) != 0) {
+		test_failed(t, "%s != %s", ptr, expect);
+		return;
+	}
+
+	(void) free(ptr);
+	test_passed(t);
+}
+
+void
+case_badf(void)
+{
+	int fd = -1;
+	int rv;
+	char *args[] = { "uname", NULL };
+	char *env[] = { NULL };
+
+	rv = fexecve(fd, args, env);
+	if (rv != -1) {
+		(void) printf("rv is not -1\n");
+		(void) exit(0);
+	}
+	if (errno != EBADF) {
+		(void) printf("err %d(%s) != EBADF\n", errno, strerror(errno));
+		(void) exit(0);
+	}
+	(void) printf("GOOD\n");
+	(void) exit(0);
+}
+
+void
+case_notexec(void)
+{
+	int fd;
+	int rv;
+	char *args[] = { "uname", NULL };
+	char *env[] = { NULL };
+
+	fd = open("/usr/bin/uname", O_RDONLY);
+
+	rv = fexecve(fd, args, env);
+	if (rv != -1) {
+		(void) printf("rv is not -1\n");
+		(void) exit(0);
+	}
+	(void) printf("FAILURE\n");
+	(void) exit(0);
+}
+
+void
+case_uname(void)
+{
+	int fd;
+	char *args[] = { "uname", NULL };
+	char *env[] = { NULL };
+
+	fd = open("/usr/bin/uname", O_EXEC);
+	if (fd < 0) {
+		(void) printf("failed to open /usr/bin/uname: %s",
+		    strerror(errno));
+		(void) exit(0);
+	}
+
+	(void) fexecve(fd, args, env);
+	(void) printf("EXEC FAILED: %s\n", strerror(errno));
+	(void) exit(0);
+}
+
+void
+case_uname_r(void)
+{
+	int fd;
+	char *args[] = { "uname", "-r", NULL };
+	char *env[] = { NULL };
+
+	fd = open("/usr/bin/uname", O_EXEC);
+	if (fd < 0) {
+		(void) printf("failed to open /usr/bin/uname: %s",
+		    strerror(errno));
+		(void) exit(0);
+	}
+
+	(void) fexecve(fd, args, env);
+	(void) printf("EXEC FAILED: %s\n", strerror(errno));
+	(void) exit(0);
+}
+
+void
+test_fexecve_badf(void)
+{
+	forkit("fexecve (bad FD)", "GOOD\n", case_badf);
+}
+
+void
+test_fexecve_notexec(void)
+{
+	forkit("fexecve (not O_EXEC)", un.sysname, case_notexec);
+}
+
+void
+test_fexecve_uname(void)
+{
+	forkit("fexecve (uname)", un.sysname, case_uname);
+}
+
+void
+test_fexecve_uname_r(void)
+{
+	forkit("fexecve (uname)", un.release, case_uname_r);
+}
+
+int
+main(int argc, char **argv)
+{
+	int optc;
+
+	(void) uname(&un);
+
+	while ((optc = getopt(argc, argv, "dfD")) != EOF) {
+		switch (optc) {
+		case 'd':
+			test_set_debug();
+			break;
+		case 'f':
+			test_set_force();
+			break;
+		case 'D':
+			test_set_debug();
+			extra_debug++;
+			break;
+		default:
+			(void) fprintf(stderr, "Usage: %s [-dfD]\n", argv[0]);
+			exit(1);
+		}
+	}
+
+	test_fexecve_badf();
+	test_fexecve_notexec();
+	test_fexecve_uname();
+	test_fexecve_uname_r();
+
+	exit(0);
+}
--- old/usr/src/uts/common/os/exec.c	Mon Apr  6 11:47:39 2015
+++ new/usr/src/uts/common/os/exec.c	Mon Apr  6 11:47:39 2015
@@ -20,6 +20,7 @@
  */
 
 /*
+ * Copyright 2015 Garrett D'Amore <garrett@damore.org>
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
@@ -98,6 +99,8 @@
 
 #define	PSUIDFLAGS		(SNOCD|SUGID)
 
+#define	DEVFD			"/dev/fd/"
+
 /*
  * exece() - system call wrapper around exec_common()
  */
@@ -198,7 +201,22 @@
 	if ((error = pn_get((char *)fname, UIO_USERSPACE, &pn)) != 0)
 		goto out;
 	pn_alloc(&resolvepn);
-	if ((error = lookuppn(&pn, &resolvepn, FOLLOW, &dir, &vp)) != 0) {
+
+	if (strncmp(pn.pn_path, DEVFD, strlen(DEVFD)) == 0) {
+		/* looks like a /dev/fd node */
+		char *p = pn.pn_path + strlen(DEVFD);
+		int fd = stoi(&p);
+		if ((fd < 0) || (*p != 0) || (p == pn.pn_path)) {
+			error = EBADF;
+			goto out;
+		}
+		if ((error = fgetstartvp(fd, NULL, &vp)) != 0) {
+			goto out;	/* error will be EBADF */
+		}
+		(void) pn_set(&resolvepn, pn.pn_path);
+
+	} else if ((error =
+	    lookuppn(&pn, &resolvepn, FOLLOW, &dir, &vp)) != 0) {
 		pn_free(&resolvepn);
 		pn_free(&pn);
 		if (error != EINVAL)
