-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\" and Copyright (c) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
.\" 2007-09-14 Ollie Wild <aaw@google.com>, mtk
.\" Add text describing limits on command-line arguments + environment
.\"
-.TH EXECVE 2 2012-05-04 "Linux" "Linux Programmer's Manual"
+.TH EXECVE 2 2014-01-08 "Linux" "Linux Programmer's Manual"
.SH NAME
execve \- execute program
.SH SYNOPSIS
associated with the file being executed.
\fIenvp\fP is an array of strings, conventionally of the form
\fBkey=value\fP, which are passed as environment to the new program.
-Both \fIargv\fP and \fIenvp\fP must be terminated by a NULL pointer.
+Both \fIargv\fP and \fIenvp\fP must be terminated by a null pointer.
The argument vector and environment can be accessed by the
called program's main function, when it is defined as:
If the set-user-ID bit is set on the program file pointed to by
\fIfilename\fP,
-and the underlying file system is not mounted
+and the underlying filesystem is not mounted
.I nosuid
(the
.B MS_NOSUID
.B PR_SET_KEEPCAPS
flag is cleared.
.IP *
+(Since Linux 2.4.36 / 2.6.23)
+If a set-user-ID or set-group-ID program is being executed,
+then the parent death signal set by
+.BR prctl (2)
+.B PR_SET_PDEATHSIG
+flag is cleared.
+.IP *
The process name, as set by
.BR prctl (2)
.B PR_SET_NAME
.IR "ps\ \-o comm" ),
is reset to the name of the new executable file.
.IP *
+The
+.B SECBIT_KEEP_CAPS
+.I securebits
+flag is cleared.
+See
+.BR capabilities (7).
+.IP *
The termination signal is reset to
.B SIGCHLD
(see
is the series of words pointed to by the
.I argv
argument of
-.BR execve ().
+.BR execve (),
+starting at
+.IR argv [1].
For portable use,
.I optional-arg
should either be absent, or be specified as a single word (i.e., it
should not contain white space); see NOTES below.
-.SS "Limits on size of arguments and environment"
+.SS Limits on size of arguments and environment
Most UNIX implementations impose some limit on the total size
of the command-line argument
.RI ( argv )
Additionally, the limit per string is 32 pages (the kernel constant
.BR MAX_ARG_STRLEN ),
and the maximum number of strings is 0x7FFFFFFF.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
On success,
.BR execve ()
does not return, on error \-1 is returned, and
Execute permission is denied for the file or a script or ELF interpreter.
.TP
.B EACCES
-The file system is mounted
+The filesystem is mounted
.IR noexec .
.TP
.B EFAULT
.I filename
+or one of the pointers in the vectors
+.I argv
+or
+.I envp
points outside your accessible address space.
.TP
.B EINVAL
or a script or ELF interpreter is not a directory.
.TP
.B EPERM
-The file system is mounted
+The filesystem is mounted
.IR nosuid ,
the user is not the superuser,
and the file has the set-user-ID or set-group-ID bit set.
.TP
.B ETXTBSY
Executable was open for writing by one or more processes.
-.SH "CONFORMING TO"
+.SH CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001.
POSIX.1-2001 does not document the #! behavior
but is otherwise compatible.
Linux ignores the set-user-ID and set-group-ID bits on scripts.
-The result of mounting a file system
+The result of mounting a filesystem
.I nosuid
varies across Linux kernel versions:
some will refuse execution of set-user-ID and set-group-ID
.I optional-arg
are used to delimit the arguments.
-On Linux,
+On Linux, either
.I argv
+or
+.I envp
can be specified as NULL,
-which has the same effect as specifying this argument
-as a pointer to a list containing a single NULL pointer.
+which has the same effect as specifying these arguments
+as a pointer to a list containing a single null pointer.
.B "Do not take advantage of this misfeature!"
It is nonstandard and nonportable:
on most other UNIX systems doing this will result in an error
Since UNIX V7 both are NULL.
.SH EXAMPLE
The following program is designed to be execed by the second program below.
-It just echoes its command-line one per line.
+It just echoes its command-line arguments, one per line.
.in +4n
.nf
char *newenviron[] = { NULL };
if (argc != 2) {
- fprintf(stderr, "Usage: %s <file-to-exec>\\n", argv[0]);
- exit(EXIT_FAILURE);
+ fprintf(stderr, "Usage: %s <file\-to\-exec>\\n", argv[0]);
+ exit(EXIT_FAILURE);
}
newargv[0] = argv[1];
argv[4]: world
.fi
.in
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR chmod (2),
.BR fork (2),
.BR ptrace (2),
.BR environ (7),
.BR path_resolution (7),
.BR ld.so (8)
+.SH COLOPHON
+This page is part of release 3.65 of the Linux
+.I man-pages
+project.
+A description of the project,
+and information about reporting bugs,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.