1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified Wed Jul 21 22:47:01 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
29 .\" Modified Fri Jan 31 16:24:28 1997 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified Fri Nov 12 22:57:27 1999 by Urs Thuermann <urs@isnogud.escape.de>
32 .TH EXECVE 2 1997-09-03 "Linux 2.0.30" "Linux Programmer's Manual"
34 execve \- execute program
36 .B #include <unistd.h>
38 .BI "int execve(const char *" filename ", char *const " argv
39 .BI "[], char *const " envp []);
41 \fBexecve()\fP executes the program pointed to by \fIfilename\fP.
42 \fIfilename\fP must be either a binary executable, or a script
43 starting with a line of the form "\fB#! \fIinterpreter \fR[arg]".
44 In the latter case, the interpreter must be a valid pathname for an
45 executable which is not itself a script, which will be invoked as
46 \fBinterpreter\fR [arg] \fIfilename\fR.
48 \fIargv\fP is an array of argument strings passed to the new program.
49 \fIenvp\fP is an array of strings, conventionally of the form
50 \fBkey=value\fR, which are passed as environment to the new
51 program. Both, \fIargv\fP and \fIenvp\fP must be terminated by a null
52 pointer. The argument vector and environment can be accessed by the
53 called program's main function, when it is defined as \fBint main(int
54 argc, char *argv[], char *envp[])\fR.
56 \fBexecve()\fP does not return on success, and the text, data, bss, and
57 stack of the calling process are overwritten by that of the program
58 loaded. The program invoked inherits the calling process's PID, and any
59 open file descriptors that are not set to close on exec. Signals pending
60 on the calling process are cleared. Any signals set to be caught by
61 the calling process are reset to their default behaviour.
62 The SIGCHLD signal (when set to SIG_IGN) may or may not be reset to SIG_DFL.
64 If the current program is being ptraced, a \fBSIGTRAP\fP is sent to it
65 after a successful \fBexecve()\fP.
67 If the set-uid bit is set on the program file pointed to by
68 \fIfilename\fP the effective user ID of the calling process is changed
69 to that of the owner of the program file. Similarly, when the set-gid
70 bit of the program file is set the effective group ID of the calling
71 process is set to the group of the program file.
73 If the executable is an a.out dynamically-linked binary executable containing
74 shared-library stubs, the Linux dynamic linker
76 is called at the start of execution to bring needed shared libraries into core
77 and link the executable with them.
79 If the executable is a dynamically-linked ELF executable, the
80 interpreter named in the PT_INTERP segment is used to load the needed
81 shared libraries. This interpreter is typically
82 \fI/lib/ld-linux.so.1\fR for binaries linked with the Linux libc
83 version 5, or \fI/lib/ld-linux.so.2\fR for binaries linked with the
86 On success, \fBexecve()\fP does not return, on error \-1 is returned, and
92 The file or a script interpreter is not a regular file.
95 Execute permission is denied for the file or a script or ELF interpreter.
98 The file system is mounted
102 The file system is mounted
104 the user is not the superuser, and the file has an SUID or SGID bit set.
107 The process is being traced, the user is not the superuser and the
108 file has an SUID or SGID bit set.
111 The argument list is too big.
114 An executable is not in a recognised format, is for the wrong
115 architecture, or has some other format error that means it cannot be
120 points outside your accessible address space.
129 or a script or ELF interpreter does not exist, or a shared library
130 needed for file or interpreter cannot be found.
133 Insufficient kernel memory was available.
136 A component of the path prefix of
138 or a script or ELF interpreter is not a directory.
141 Search permission is denied on a component of the path prefix of
143 or the name of a script interpreter.
146 Too many symbolic links were encountered in resolving
148 or the name of a script or ELF interpreter.
151 Executable was open for writing by one or more processes.
154 An I/O error occurred.
157 The limit on the total number of files open on the system has been reached.
160 The process has the maximum number of files open.
163 An ELF executable had more than one PT_INTERP segment (i.e., tried to
164 name more than one interpreter).
167 An ELF interpreter was a directory.
170 An ELF interpreter was not in a recognised format.
172 SVr4, SVID, X/OPEN, BSD 4.3. POSIX does not document the #! behavior
173 but is otherwise compatible. SVr4 documents additional error
174 conditions EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP; POSIX does not
175 document ETXTBSY, EPERM, EFAULT, ELOOP, EIO, ENFILE, EMFILE, EINVAL,
176 EISDIR or ELIBBAD error conditions.
178 SUID and SGID processes can not be \fBptrace()\fPd.
180 Linux ignores the SUID and SGID bits on scripts.
182 The result of mounting a filesystem
184 vary between Linux kernel versions:
185 some will refuse execution of SUID/SGID executables when this would
186 give the user powers she did not have already (and return EPERM),
187 some will just ignore the SUID/SGID bits and exec successfully.
189 A maximum line length of 127 characters is allowed for the first line in
190 a #! executable shell script.
192 .\" Some Linux versions have failed to check permissions on ELF
193 .\" interpreters. This is a security hole, because it allows users to
194 .\" open any file, such as a rewinding tape device, for reading. Some
195 .\" Linux versions have also had other security holes in \fBexecve()\fP,
196 .\" that could be exploited for denial of service by a suitably crafted
197 .\" ELF binary. There are no known problems with 2.0.34 or 2.2.15.