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]". 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().

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
    filename contains a circular reference (i.e., via a symbolic link)

CONFORMING TO
SVID, AT&T, POSIX, X/OPEN, BSD 4.3

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. This may be circumvented by changing the max size of buf, in which case you will become bound by the 1024 byte size of a buffer, which is not easily worked around.

SEE ALSO
execl(3), fork(2)