1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\"
.\" 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.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified Wed Jul 21 22:47:01 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
.\" Fixed typoes.
.\" Modified Fri Jan 31 16:24:28 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Fri Nov 12 22:57:27 1999 by Urs Thuermann <urs@isnogud.escape.de>
.\"
.TH EXECVE 2 "3 September 1997" "Linux 2.0.30" "Linux Programmer's Manual"
.SH NAME
execve \- execute program
.SH SYNOPSIS
.B #include <unistd.h>
.sp
.BI "int execve (const char *" filename ", char *const " argv
.BI "[], char *const " envp []);
.SH DESCRIPTION
\fBexecve()\fP executes the program pointed to by \fIfilename\fP.
\fIfilename\fP must be either a binary executable, or a script
starting with a line of the form "\fB#! \fIinterpreter \fR[arg]".
In the latter case, the interpreter must be a valid pathname for an
executable which is not itself a script, which will be invoked as
\fBinterpreter\fR [arg] \fIfilename\fR.
\fIargv\fP is an array of argument strings passed to the new program.
\fIenvp\fP is an array of strings, conventionally of the form
\fBkey=value\fR, which are passed as environment to the new
program. 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 \fBint main(int
argc, char *argv[], char *envp[])\fR.
\fBexecve()\fP does not return on success, and the text, data, bss, and
stack of the calling process are overwritten by that of the program
loaded. The program invoked inherits the calling process's PID, and any
open file descriptors that are not set to close on exec. Signals pending
on the calling process are cleared. Any signals set to be caught by
the calling process are reset to their default behaviour.
If the current program is being ptraced, a \fBSIGTRAP\fP is sent to it
after a successful \fBexecve()\fP.
If the set-uid bit is set on the program file pointed to by
\fIfilename\fP the effective user ID of the calling process is changed
to that of the owner of the program file. Similarly, when the set-gid
bit of the program file is set the effective group ID of the calling
process is set to the group of the program file.
If the executable is an a.out dynamically-linked binary executable containing
shared-library stubs, the Linux dynamic linker
.BR ld.so (8)
is called at the start of execution to bring needed shared libraries into core
and link the executable with them.
If the executable is a dynamically-linked ELF executable, the
interpreter named in the PT_INTERP segment is used to load the needed
shared libraries. This interpreter is typically
\fI/lib/ld-linux.so.1\fR for binaries linked with the Linux libc
version 5, or \fI/lib/ld-linux.so.2\fR for binaries linked with the
GNU libc version 2.
.SH "RETURN VALUE"
On success, \fBexecve()\fP does not return, on error \-1 is returned, and
.I errno
is set appropriately.
.SH ERRORS
.TP
.B EACCES
The file or a script interpreter is not a regular file.
.TP
.B EACCES
Execute permission is denied for the file or a script interpreter.
.TP
.B EACCES
The file system is mounted
.IR noexec .
.TP
.B EPERM
The file system is mounted
.IR nosuid ,
the user is not the superuser, and the file has an SUID or SGID bit set.
.TP
.B EPERM
The process is being traced, the user is not the superuser and the
file has an SUID or SGID bit set.
.TP
.B E2BIG
The argument list is too big.
.TP
.B ENOEXEC
An executable is not in a recognised format, is for the wrong
architecture, or has some other format error that means it cannot be
executed.
.TP
.B EFAULT
.I filename
points outside your accessible address space.
.TP
.B ENAMETOOLONG
.I filename
is too long.
.TP
.B ENOENT
The file
.I filename
or a script or ELF interpreter does not exist.
.TP
.B ENOMEM
Insufficient kernel memory was available.
.TP
.B ENOTDIR
A component of the path prefix of
.I filename
or a script or ELF interpreter is not a directory.
.TP
.B EACCES
Search permission is denied on a component of the path prefix of
.I filename
or the name of a script interpreter.
.TP
.B ELOOP
Too many symbolic links were encountered in resolving
.I filename
or the name of a script or ELF interpreter.
.TP
.B ETXTBUSY
Executable was open for writing by one or more processes.
.TP
.B EIO
An I/O error occurred.
.TP
.B ENFILE
The limit on the total number of files open on the system has been reached.
.TP
.B EMFILE
The process has the maximum number of files open.
.TP
.B EINVAL
An ELF executable had more than one PT_INTERP segment (i.e., tried to
name more than one interpreter).
.TP
.B EISDIR
An ELF interpreter was a directory.
.TP
.B ELIBBAD
An ELF interpreter was not in a recognised format.
.SH "CONFORMING TO"
SVr4, SVID, X/OPEN, BSD 4.3. POSIX does not document the #! behavior
but is otherwise compatible. SVr4 documents additional error
conditions EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP; POSIX does not
document ETXTBSY, EPERM, EFAULT, ELOOP, EIO, ENFILE, EMFILE, EINVAL,
EISDIR or ELIBBAD error conditions.
.SH NOTES
SUID and SGID processes can not be \fBptrace()\fPd SUID or SGID.
A maximum line length of 127 characters is allowed for the first line in
a #! executable shell script.
Linux ignores the SUID and SGID bits on scripts.
.SH "SEE ALSO"
.BR chmod (2),
.BR fork (2),
.BR execl (3),
.BR environ (5),
.BR ld.so (8)
|