.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)execve.2 6.8 (Berkeley) %G%
char *path, **argv, **envp;
transforms the calling process into a new process.
The new process is constructed from an ordinary file,
whose name is pointed to by
called the \fInew process file\fP.
This file is either an executable object file,
or a file of data for an interpreter.
An executable object file consists of an identifying header,
followed by pages of data representing the initial program (text)
and initialized data pages. Additional pages may be specified
by the header to be initialized with zero data. See
An interpreter file begins with a line of the form
.RB `` "#! \fIinterpreter\fP [\fIarg\fP]" ''.
When an interpreter file is
the system \fIexecve\fP\|'s the specified \fIinterpreter\fP.
is specified, it becomes the first argument to the
and the name of the originally
file becomes the second argument;
otherwise, the name of the originally
file becomes the first argument. The original arguments are shifted over to
become the subsequent arguments. The zeroth argument, normally the name of the
There can be no return from a successful \fIexecve\fP because the calling
This is the mechanism whereby different process images become active.
The argument \fIargv\fP is a pointer to a null-terminated array of
character pointers to null-terminated character strings.
These strings constitute the argument list to be made available to the new
process. By convention, at least one argument must be present in
this array, and the first element of this array should be
the name of the executed program (i.e., the last component of \fIpath\fP).
The argument \fIenvp\fP is also a pointer to a null-terminated array of
character pointers to null-terminated strings.
These strings pass information to the
new process that is not directly an argument to the command (see
Descriptors open in the calling process remain open in
the new process, except for those for which the close-on-exec
Descriptors that remain open are unaffected by
Ignored signals remain ignored across an
but signals that are caught are reset to their default values.
Blocked signals remain blocked regardless of changes to the signal action.
The signal stack is reset to be undefined (see
user and group IDs and an
ID identifies the person using the system; the
ID determines his access privileges.
changes the effective user and group ID to
the owner of the executed file if the file has the \*(lqset-user-ID\*(rq
or \*(lqset-group-ID\*(rq modes. The
user and group IDs are not affected.
The new process also inherits the following attributes from
process ID see \fIgetpid\fP\|(2)
parent process ID see \fIgetppid\fP\|(2)
process group ID see \fIgetpgrp\fP\|(2)
access groups see \fIgetgroups\fP\|(2)
working directory see \fIchdir\fP\|(2)
root directory see \fIchroot\fP\|(2)
control terminal see \fItty\fP\|(4)
resource usages see \fIgetrusage\fP\|(2)
interval timers see \fIgetitimer\fP\|(2)
resource limits see \fIgetrlimit\fP\|(2)
file mode mask see \fIumask\fP\|(2)
signal mask see \fIsigvec\fP\|(2), \fIsigsetmask\fP\|(2)
When the executed program begins, it is called as follows:
is the number of elements in \fIargv\fP
points to the array of character pointers
to the arguments themselves.
is a pointer to an array of strings that constitute
A pointer to this array is also stored in the global variable ``environ''.
Each string consists of a name, an \*(lq=\*(rq, and a null-terminated value.
The array of pointers is terminated by a null pointer.
passes an environment entry for each global shell variable
defined when the program is called.
returns to the calling process an error has occurred; the
return value will be \-1 and the global variable
will contain an error code.
will fail and return to the calling process if one or more
of the following are true:
A component of the path prefix is not a directory.
The pathname contains a character with the high-order bit set.
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
The new process file does not exist.
Too many symbolic links were encountered in translating the pathname.
Search permission is denied for a component of the path prefix.
The new process file is not an ordinary file.
The new process file mode denies execute permission.
The new process file has the appropriate access
permission, but has an invalid magic number in its header.
The new process file is a pure procedure (shared text)
file that is currently open for writing or reading by some process.
The new process requires more virtual memory than
is allowed by the imposed maximum
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 20480 bytes
The new process file is not as long as indicated by
the size values in its header.
\fIPath\fP\|, \fIargv\fP\|, or \fIenvp\fP point
An I/O error occurred while reading from the file system.
to a non-super-user, but is executed when
the real \fIuid\fP is ``root'', then the program has some of the powers
exit(2), fork(2), execl(3), environ(7)