Open System Services System Calls Reference Manual (G06.25+, H06.03+)

exec(2) OSS System Calls Reference Manual
NAME
exec - Species a set of functions that execute a file
DESCRIPTION
The exec set of functions (execl(), execle(), execlp(), execv(), execve(), and execvp()) replace
the current process image with a new process image. The new image is constructed from a regu-
lar executable file, called a new process image file. The new process image file is formatted as
an executable text or binary file in one of the formats recognized by the exec set of functions.
A successful call to any function in the exec set of functions does not return, because the calling
process image is overlaid by the new process image.
When a program is executed as a result of a call to a function in the exec set of functions, it is
entered as a function call as follows:
int main(
int argc,
char argv[],
char env[]);
Here, the argc parameter is the argument count, the argv[]parameter is an array of character
pointers to the arguments themselves, and env[]is a pointer to a character array listing the
environment variables.
In addition, the following variable is initialized for the new process as a pointer to an array of
character pointers to the environment strings:
extern char ∗∗environ;
The argv[]array is terminated by a null pointer. The null pointer is not counted in argc.
The arguments specified by a program with one of the exec set of functions are passed on to the
new process image in the corresponding arguments to the main() function.
The env[]parameter for the main function is an HP extension and is not the preferred method of
obtaining the environment variables for the child process. Use of the **environ array is the pre-
ferred method.
For additional information, refer to the reference page for a specific function in the exec set of
functions.
RELATED INFORMATION
Commands: eld(1), ld(1), nld(1).
Functions: alarm(3), _exit(2), execl(2), execle(2), execlp(2), execv(2), execve(2), execvp(2),
fcntl(2), fork(2), getenv(3), putenv(3), semget(2), sigaction(2), system(3), tdm_execve(2),
tdm_execvep(2), tdm_fork(2), tdm_spawn(2), tdm_spawnp(2), times(3), ulimit(3), umask(2).
Miscellaneous: environ(5).
22 Hewlett-Packard Company 527186-003