EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) NAME NAME NAME NAME execl, execv, execle, execve, execlp, execvp - execute a file SYNOPSIS SYNOPSIS SYNOPSIS SYNOPSIS int execl (path, arg0, arg1, ..., argn, 0) char *path, *arg0, *arg1, ..., *argn; int execv (path, argv) char *path, *argv[ ]; int execle (path, arg0, arg1, ..., argn, 0, envp) char *path, *arg0, *arg1, ..., *argn, *envp[ ]; int execve (path, argv, envp); char *path, *argv[ ], *envp[ ]; int execlp (file, arg0, arg1, ..., argn, 0) char *file, *arg0, *arg1, ..., *argn; int execvp (file, argv) char *file, *argv[ ]; DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION Exec in all its forms transforms the calling process into a new process. The new process is constructed from an ordinary, executable file called the "new process file". This file consists of a header (see a.out (5)), a text segment, and a data segment. The data segment contains an initialized portion and an uninitialized portion (bss). There can be no return from a successful exec because the calling process is overlaid by the new process. Path points to a path name that identifies the new process file. File points to the new process file. The path prefix for this file is obtained by a search of the directories passed as the environment line "PATH =" (see environ (7)). The environment is supplied by the shell (see sh (1)). Arg0 , arg1 , ... , argn are pointers to null-terminated character strings. These strings constitute the argument list available to the new process. By convention, at least arg0 must be present and point to a string that is the same as path (or its last component). Argv is an array of character pointers to null-terminated strings. These strings constitute the argument list available to the new process. By convention, argv must have at least one member, and it must point to a string that is the same as path (or its last component). Argv is Hewlett-Packard - 1 - (printed 12/12/84) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) terminated by a null pointer. Envp is an array of character pointers to null-terminated strings. These strings constitute the environment for the new process. Envp is terminated by a null pointer. File descriptors open in the calling process remain open in the new process, except for those whose close-on-exec flag is set; see fcntl (2). For those file descriptors that remain open, the file pointer is unchanged. Signals set to terminate the calling process will be set to terminate the new process. Signals set to be ignored by the calling process will be set to be ignored by the new process. Signals set to be caught by the calling process will be set to terminate new process; see signal (2). If the set-user-ID mode bit of the new process file is set (see chmod (2)), exec sets the effective user ID of the new process to the owner ID of the new process file. Similarly, if the set-group-ID mode bit of the new process file is set, the effective group ID of the new process is set to the group ID of the new process file. The real user ID and real group ID of the new process remain the same as those of the calling process. Profiling is disabled for the new process; see profil (2). The new process also inherits the following attributes from the calling process: nice value (see nice (2)) process ID parent process ID process group ID tty group ID (see exit (2) and signal (2)) trace flag (see ptrace (2) request 0) time left until an alarm clock signal (see alarm (2)) current working directory root directory file mode creation mask (see umask (2)) file size limit (see ulimit (2)) utime , stime , cutime , and cstime (see times (2)) Exec will fail and return to the calling process if one or more of the following are true: One or more components of the new process file's path name do not exist. [ENOENT] A component of the new process file's path prefix is not a directory. [ENOTDIR] Hewlett-Packard - 2 - (printed 12/12/84) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) EXEC(2) HP Integral PC EXEC(2) Search permission is denied for a directory listed in the new process file's path prefix. [EACCES] The new process file is not an ordinary file. [EACCES] The new process file mode denies execution permission. [EACCES] The new process file has the appropriate access permission, but has an invalid magic number in its header. [ENOEXEC] The new process file is a pure procedure (shared text) file that is currently open for writing by some process. [ETXTBSY] The new process requires more memory than is allowed by the system-imposed maximum MAXMEM. [ENOMEM] The number of bytes in the new process's argument list is greater than the system-imposed limit of 5120 bytes. [E2BIG] The new process file is not as long as indicated by the size values in its header. [EFAULT] Path , argv , or envp point to an illegal address. [EFAULT] RETURN VALUE RETURN VALUE RETURN VALUE RETURN VALUE If exec returns to the calling process an error has occurred; the return value will be -1 and errno will be set to indicate the error. SEE ALSO SEE ALSO SEE ALSO SEE ALSO exit(2), fork(2). Hewlett-Packard - 3 - (printed 12/12/84)