.\" 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 .\" Modified Wed Jul 21 22:47:01 1993 by Rik Faith .\" Modified 21 Aug 1994 by Michael Chastain : .\" Fixed typoes. .\" Modified Fri Jan 31 16:24:28 1997 by Eric S. Raymond .\" .TH EXECVE 2 "21 August 1994" "Linux 1.1.46" "Linux Programmer's Manual" .SH NAME execve \- execute program .SH SYNOPSIS .B #include .sp .BI "int execve (const char *" filename ", const char *" argv .BI "[], const char *" envp []); .SH DESCRIPTION \fBexecve()\fP executes the program pointed to by \fIfilename\fP. \fIfilename\fP must be either a binary executable, or a shell script starting with a line of the form "\fB#! \fIinterpreter \fR[arg]". In the latter case, the interpreter must be a valid full executable pathname and the contents of .I filename is presented to it on standard input. \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 parent process are cleared. If the current program is being ptraced, a \fBSIGTRAP\fP is sent to it after a successful \fBexecve()\fP. If the executable is a dynamically-linked binary executable containing shared-library stubs, the Linux dynamic linker .IR ld.so (1) is called before execution to bring needed shared libraries into core and link the executable with them. .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 is not a regular file. .TP .B EACCES Execute permission is denied for the file. .TP .B EPERM The file system is mounted .IR noexec . .TP .B EPERM The file system is mounted .I nosuid and the file has an SUID or SGID bit set. .TP .B E2BIG The argument list is too big. .TP .B ENOEXEC The magic number in the file is incorrect. .TP .B EFAULT .I filename points outside your accessible address space. .TP .B ENAMETOOLONG .I filename is too long. .TP .B ENOENT The file does not exist. .TP .B ENOMEM Insufficient kernel memory was available. .TP .B ENOTDIR A component of the path prefix is not a directory. .TP .B EACCES Search permission is denied on a component of the path prefix. .TP .B ELOOP .TP .B ETXTBUSY Executable was open for writing by one or more processes. .I filename contains a circular reference (i.e., via a symbolic link) .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 or ENOMEM 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. .SH "SEE ALSO" .BR ld.so "(1)," .BR execl "(3)," .BR fork (2)