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 the magic number #!. 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. On error, a negative number is returned.

If the current program is being ptraced, a SIGTRAP is sent to it after a successful execve().

ERRORS
-EACCESS is returned when the permissions do not allow the file to be executed.

-ENOENT is returned when the file does not exist.

-ENOEXEC is returned when a bad magic number is found or a shell cannot be found for a #! executable.

-ENOMEM is returned when there is insufficient memory to exec().

FILES
linux/fs/exec.c
linux/kernel/sys_call.s
/usr/include/linux/sys.h
/usr/include/unistd.h
/bin/sh, and user specified shells.

SEE ALSO
execl(3), fork(2)

BUGS
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.