execve, rexecve − execute a file execve(name, argv, envp)
char *name, *argv[], *envp[];
transforms the calling process into a new process. The new process is constructed from an ordinary file called the new process file. This file must be an executable object file. 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 There can be no return from a successful execve because the calling core image may have been lost. When a program invoked via execve exits, control is returned to the monitor. In situations where the calling programs knows that the called program will not destroy the calling programs memory image rexecve may be used to cause control to return to the calling program when the called program exits. In this case, the value returned by rexecve is the exit code of the called program. The argument argv is 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 name). The argument envp is also 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 When the executed program begins, it is called as follows:
main(argc, argv, envp)
int argc;
char **argv, **envp;
where is the number of elements in argv (the “arg count”) and is the array of character pointers to the arguments themselves. is a pointer to an array of strings that constitute the of the process. A pointer to this array is also stored in the global variable “environ”. Each string consists of a name, an “=”, and a null-terminated value. The array of pointers is terminated by a null pointer. The shell passes an environment entry for each global shell variable defined when the program is called. See for some conventionally used names. If 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 return -1 if the new process image could not be loaded and the global variable will contain an error code; otherwise, will return the exit code of the called program.