When a program is executed as a result of an
execve();
call, it is entered as follows:
main(int argc, char **argv, char **envp)
where
argc
is the number of elements in
argv
(the
arg count)
and
argv
points to the array of character pointers
to the arguments themselves.
The
exect();
function is equivalent to
execve();
with the additional property that it executes the file with the program
tracing facilities enabled (see
ptrace(2/)).
RETURN VALUES
As the
execve();
function overlays the current process image
with a new process image the successful call
has no process to return to.
If
execve();
does return to the calling process an error has occurred; the
return value will be \-1 and the global variable
errno
is set to indicate the error.
ERRORS
execve();
will fail and return to the calling process if:
- [ENOTDIR]
-
A component of the path prefix is not a directory.
- [ENAMETOOLONG]
-
A component of a pathname exceeded
{NAME_MAX}
characters, or an entire path name exceeded
{PATH_MAX}
characters.
- [ENOENT]
-
The new process file does not exist.
- [ELOOP]
-
Too many symbolic links were encountered in translating the pathname.
- [EACCES]
-
Search permission is denied for a component of the path prefix.
- [EACCES]
-
The new process file is not an ordinary file.
- [EACCES]
-
The new process file mode denies execute permission.
- [EACCES]
-
The new process file is on a filesystem mounted with execution
disabled
.Pf ( Dv MNT_NOEXEC
in
sys/mount.h ).
- [ENOEXEC]
-
The new process file has the appropriate access
permission, but has an invalid magic number in its header.
- [ETXTBSY]
-
The new process file is a pure procedure (shared text)
file that is currently open for writing or reading by some process.
- [ENOMEM]
-
The new process requires more virtual memory than
is allowed by the imposed maximum
(getrlimit(2)).
- [E2BIG]
-
The number of bytes in the new process's argument list
is larger than the system-imposed limit.
The limit in the system as released is 262144 bytes
.Pf ( Dv NCARGS
in
sys/param.h ).
- [EFAULT]
-
The new process file is not as long as indicated by
the size values in its header.
- [EFAULT]
-
path,
argv,
or
envp
point
to an illegal address.
- [EIO]
-
An I/O error occurred while reading from the file system.
- [ENFILE]
-
During startup of an
interpreter,
the system file table was found to be full.
SEE ALSO
_exit(2),
fork(2),
execl(3),
exit(3),
a.out(5),
elf(5),
environ(7)
STANDARDS
The
exect();
function should not be used in portable applications.
HISTORY
The
execve();
function call first appeared in
Version 7 AT&T UNIX
and
3BSD.
CAVEATS
If a program is
setuid
to a non-superuser, but is executed when the real
uid
is
root,
then the program has some of the powers of a superuser as well.
| AerieBSD 1.0 Reference Manual |
May 14 2010 |
EXECVE(2) |