Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ execve(2) — UTek W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

exit(2)

fork(2)

getrlimit(2)

sigvec(2)

execl(3c)

a.out(5)

environ(7)



EXECVE(2)               COMMAND REFERENCE               EXECVE(2)



NAME
     execve - execute a file

SYNOPSIS
     execve(path, argv, envp)
     char *path, *argv[], *envp[];

DESCRIPTION
     Execve transforms the calling process into a new process.
     The new process is constructed from path, an ordinary file
     called the new process file.  This file is either an
     executable object file, or a file of data for an
     interpreter.  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
     initialize with zero data.  See a.out(5).

     An interpreter file begins with a line of the form ``#!
     interpreter''.  The length of this line cannot exceed
     SHSIZE, defined in <sys/user.h> (currently 32).  When an
     interpreter file is execve'd, the system execve's the
     specified interpreter.  The original arguments are passed to
     the interpreter as one argument (arg 1) and path , the name
     of the originally execve'd file, is passed as an additional
     argument (arg 2).

     There can be no return from a successful execve because the
     calling core image is lost.  This is the mechanism whereby
     different process images become active.

     The argument argv is an 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
     path).

     The argument envp is also an array of character pointers to
     null-terminated strings.  These strings pass information to
     the new process which are not directly arguments 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 close(2).  Descriptors which remain open
     are unaffected by execve.

     Ignored signals remain ignored across an execve, but signals
     that are caught are reset to their default values.  The
     signal stack is reset to be undefined; see sigvec(2) for



Printed 10/17/86                                                1





EXECVE(2)               COMMAND REFERENCE               EXECVE(2)



     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.
     Execve changes 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 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)
          access groups       see getgroups(2)
          working directory   see chdir(2)
          root directory      see chroot(2)
          control terminal    see tty(2)
          resource usages     see getrusage(2)
          interval timers     see getitimer(2)
          resource limits     see getrlimit(2)
          file mode mask      see umask(2)
          signal mask         see sigvec(2)

     When a "C" program is executed as a result of the call, it
     is called as follows:

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

     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(1sh) passes an environment entry for each global
     shell variable defined when the program is called.  See
     environ(7) for some conventionally used names.

DIAGNOSTICS
     Execve will fail and return to the calling process if one or
     more of the following are true:

     [ENAMETOOLONG]
         The new process file's pathname is too long.




Printed 10/17/86                                                2





EXECVE(2)               COMMAND REFERENCE               EXECVE(2)



     [ENOENT]
         One or more components of the new process file's
         pathname do not exist, or the interpreter to be used to
         execute the new process file does not exist.

     [ENOTDIR]
         A component of the new process file's or the
         interpreter's pathname is not a directory.

     [EACCES]
         Search permission is denied for a directory listed in
         the new process file's or the interpreter's path prefix.

     [EACCES]
         The new process file or the interpreter is not an
         ordinary file.

     [EACCES]
         The new process file mode or the interpreter mode denies
         execute permission.  If the file is located on a remote
         host, this error code will be returned if the local host
         name and local user name does not appear in
         /usr/lib/dfs/access on the remote machine.  See
         access(dfs)(5n).

     [ENOEXEC]
         The new process file or the interpreter has the
         appropriate access permission, but has an invalid magic
         number in its header (see a.out(5)).

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

     [ENOMEM]
         The new process requires more virtual memory than is
         allowed by the imposed maximum (getrlimit(2)).

     [E2BIG]
         The number of bytes in the new process's argument list
         is larger than the system-imposed limit of NCARGS,
         defined in <sys/param.h>.

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

     [ENOEXEC]
         The interpreter name is longer than SHSIZE, defined in
         <sys/user.h>.




Printed 10/17/86                                                3





EXECVE(2)               COMMAND REFERENCE               EXECVE(2)



     [EIO]
         An I/O error occurred while reading from or writing to
         the file system.

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

     [ENOMEM]
         Swap space is not available for the new process, or the
         new process file's textsize, datasize or stacksize
         exceed the system-imposed limits MAXTSIZ, MAXDSIZ or
         MAXSSIZ, defined in <machine/vmparam.h>.

     [EDFSNOSUCHHOST]
         The pathname referenced a remote host, but when we
         broadcast a request for its address, no host responded.

RETURN VALUE
     If execve returns to the calling process an error has
     occurred; the return value will be -1 and the global
     variable errno will contain an error code.

CAVEATS
     If a program is setuid to a non-super-user, but is executed
     when the real uid is ``root'', then the program has the
     powers of a super-user as well.

SEE ALSO
     close(2), exit(2), fork(2), getrlimit(2), sigvec(2),
     execl(3c), a.out(5), environ(7).

























Printed 10/17/86                                                4





































































%%index%%
na:72,59;
sy:131,411;
de:542,2665;3351,2229;
di:5580,293;6017,1871;8032,599;
rv:8631,291;
ca:8922,232;
se:9154,275;
%%index%%000000000149

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