EXECVE(2)

NAME
execve - execute program

SYNOPSIS
#include <unistd.h>

int execve (const char *filename, const char *argv [], const char *envp[]);

DESCRIPTION
execve() executes the program pointed to by filename. filename must be either a binary executable, or a shell script starting with a line of the form "#! interpreter [arg]". In the latter case, the interpreter must be a valid full executable pathname and the contents of filename is presented to it on standard input. execve() 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 SIGTRAP is sent to it after a successful execve(). If the executable is a dynamically-linked binary executable containing shared-library stubs, the Linux dynamic linker ld.so(1) is called before execution to bring needed shared libraries into core and link the executable with them.

RETURN VALUE
On success, execve() does not return, on error -1 is returned, and errno is set appropriately.

ERRORS

EACCES
    The file is not a regular file.

EACCES
    Execute permission is denied for the file.

EPERM
    The file system is mounted noexec.

EPERM
    The file system is mounted nosuid and the file has an SUID or SGID bit set.

E2BIG
    The argument list is too big.

ENOEXEC
    The magic number in the file is incorrect.

EFAULT
    filename points outside your accessible address space.

ENAMETOOLONG
    filename is too long.

ENOENT
    The file does not exist.

ENOMEM
    Insufficient kernel memory was available.

ENOTDIR
    A component of the path prefix is not a directory.

EACCES
    Search permission is denied on a component of the path prefix.

ELOOP

ETXTBUSY
    Executable was open for writing by one or more processes. filename contains a circular reference (i.e., via a symbolic link)

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.

NOTES
SUID and SGID processes can not be ptrace()d SUID or SGID. A maximum line length of 127 characters is allowed for the first line in a #! executable shell script.

SEE ALSO
ld.so(1), execl(3), fork(2)