int execv(const char*path, char *const argv[]);
extern char **environ;
An interpreter file begins with a line of the form ``#! interpreter''. When an interpreter file is exec'd, the system runs the specified interpreter,giving it the name of the originally exec'dfileasanargumentand shifting over the rest of the original arguments.
There can be no return from a successful or execv, since the calling core image is lost. This is the mechanism whereby different process images become active.
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 (that is, the last component of path).
The execve function takes an additional argument envp which is 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 environ.7
Descriptors open in the calling process remain open in the new process, except for those for which the close-on-exec flag is set (see fcntl.2 Descriptors that remain open are unaffected by execve or execv.
Directory streams open in the calling process image are closed in the new process image.
Ignored signals remain ignored across an execve or execv, 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 sigvec.2 for more information).
Each process has real user and group IDs and effective user and group IDs. The real ID identifies the person using the system; the effective ID determines his access privileges. The execve and execv functions change 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. The effective user ID and effective group ID of the new process image will be saved (as the saved set-user-ID and the saved set-group-ID) for use by the setuid.2
The new process also inherits the following attributes from the calling process:
process ID see getpid(2) parent process ID see getppid(2) process group ID see getpgrp(2) session membership see setsid(2) real user ID see getuid(2) real group ID see getgid(2) supplementary group IDs see getgroups(2) time left until an alarm clock signal see getitimer(2) current working directory see getwd(3) or getcwd(3P) root directory see chroot(2) file mode mask see umask(2) signal mask see sigprocmask(2) pending signals see sigpending(2) tms_utime, tms_stime, tms_cutime, tms_cstime see times(2) controlling terminal see tty(4) resource usages see getrusage(2) resource limits see getrlimit(2)
When the executed program begins, it is called as follows:
main(int argc, char *argv);
where argc is the number of elements in argv (the ``arg count'') and argv is the array of character pointers to the arguments themselves.
Envp is a pointer to an array of strings that constitute the environment 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 sh.1 passes an environment entry for each global shell variable defined when the program is called. See environ.7 for some conventionally used names.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97