Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

alarm(2)

exit(2)

fork(2)

nice(2)

semop(2)

signal(2)

times(2)

umask(2)

environ(5)



EXEC(2)                  DOMAIN/IX SYS5                   EXEC(2)



NAME
     execl, execv, execle, execve, execlp, execvp - execute a
     file

USAGE
     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
     Each member of the exec family transforms the process that
     called it into a new process.  The new process is con-
     structed from an executable file called the "new process
     file," which consists of a header, a text segment, and a
     data segment.  The data segment contains an initialized por-
     tion and an uninitialized (bss) portion.  No return from a
     successful exec is possible, since the calling process is
     overlaid by the new process.

     When a C program is executed, it is called as follows:

       main (argc, argv, envp)
       int argc;
       char **argv, **envp;

     where argc is the argument count and argv is an array of
     character pointers to the arguments themselves.  By conven-
     tion, the value of argc is greater than zero.  The first
     member of the array points to a string containing the name
     of the file.

     Path points to a pathname that identifies the new process
     file.





Printed 12/4/86                                            EXEC-1







EXEC(2)                  DOMAIN/IX SYS5                   EXEC(2)



     File points to the new process file.  The path prefix for
     this file comes from a search of the directories passed as
     the environment variable "PATH =" (see environ(5)).  The
     environment is supplied by the shell (see sh(1)).

     Arguments arg0 through argn are pointers to null-terminated
     character strings, which constitute the argument list avail-
     able to the new process.  By convention, at least arg0 must
     be present; it points 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 avail-
     able 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 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.  For
     execl and execv, the C run-time start-off routine places a
     pointer to the environment of the calling process in the
     global cell:

       extern char **environ

     Envp is used to pass the environment of the calling process
     to the new process.

     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 does not change.

     Signals that terminate the calling process are set to ter-
     minate the new process.  Signals that the calling process
     ignores are ignored by the new process.  Signals set to be
     caught by the calling process are set to terminate the 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.




EXEC-2                                            Printed 12/4/86







EXEC(2)                  DOMAIN/IX SYS5                   EXEC(2)



     The shared memory segments attached to the calling process
     will not be attached to the new process (see shmop(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
       semadj values (see semop(2))
       tty group ID (see exit(2) and signal(2))
       trace flag
       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
       utime, stime, cutime, and cstime (see times(2))


RETURN VALUE
     A successful call never returns.  A failed call returns -1
     and sets errno as indicated below.

ERRORS
     Exec calls fail and return to the calling process if one or
     more of the following is true:

     [ENOENT]  One or more components of the new process pathname
               of the file does not exist.

     [ENOTDIR] A component of the new process path of the file
               prefix is not a directory.

     [EACCES]  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 permis-
               sion.

     [ENOEXEC] The exec is not an execlp or execvp, and the new
               process file has the appropriate access permis-
               sion, but an invalid magic number in its header.

     [ETXTBSY] The new process file is a pure procedure (shared
               text) file that is currently open for writing by
               some process.



Printed 12/4/86                                            EXEC-3







EXEC(2)                  DOMAIN/IX SYS5                   EXEC(2)



     [ENOMEM]  The new process requires more memory than is
               allowed by the system-imposed maximum MAXMEM.

     [E2BIG]   The number of bytes in the new process's argument
               list is greater than the system-imposed limit of
               10240 bytes.

     [EFAULT]  The new process file is not as long as indicated
               by the size values in its header.

     [EFAULT]  Path, argv, or envp points to an illegal address.

RELATED INFORMATION
     alarm(2), exit(2), fork(2), nice(2), semop(2), signal(2),
     times(2), umask(2), environ(5)






































EXEC-4                                            Printed 12/4/86





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026