.th execv IV 4/21/86
.sh NAME
execv  \*-  execute a file
.sh SYNOPSIS
execv(name, argv)
.br
char *name;
.br
char *argv[ ];
.ft R
.sh DESCRIPTION
Execv overlays the calling process with the named file, then transfers
to the beginning of the core image of the file.  There can be no return
from the file; the calling core image is lost.
.s3
Files remain open across execv calls.
.s3
Each user has a real user ID and group ID and an effective user ID and
group ID.  The real ID identifies the person using the system; the
effective ID determines his access privileges.  Exec changes the
effective user and group ID to the owner of the executed file if the
file has the ``set-user-ID'' or ``set-group-ID'' modes.  The real user
ID is not affected.
.s3
Execv is useful when the number of arguments is unknown in advance.
The first argument to execv is a pointer to the name of the file to be
executed, and a vector of strings containing the arguments.  The last
argument string must be followed by a 0 pointer.
.s3
Once the called file starts execution, the arguments are available as
follows.  The stack pointer points to a word containing the number of
arguments.  Just above this number is a list of pointers to the
argument strings.  The arguments are placed as high as possible in core.
.s3
  sp\*>	nargs
.br
	arg0
.br
	...
.br
	argn
.br
	\*-1
.s3
 arg0:	<arg0\\0>
.br
	...
.br
 argn:	<argn\\0>
.s3
When a C program is executed,
it is called as follows:
.s3
	main(argc, argv)
.br
	int argc;
.br
	char **argv;
.s3
where argc is the argument count and argv is an array of character
pointers to the arguments themselves.  As indicated, argc is
conventionally at least one and the first member of the array points to
a string containing the name of the file.
.s3
Argv is not directly usable in another execv, since argv[argc] is -1
and not 0.
.sh "SEE ALSO"
fork (IV)
.sh DIAGNOSTICS
If the file cannot be found, if it is not executable, if it does not
have a valid header (407, 410, or 411 octal as first word), if maximum
memory is exceeded, or if the arguments require more than 512 bytes a
return from exec constitutes the diagnostic; the error bit (c-bit) is
set.  From C the returned value is -1.
.sh NOTES
Only 512 characters of arguments are allowed.
.sh KSOS
Set user id and set group id are not supported by the KIP.  At
present, shared text files (type 410) are not supported.
