

execution             Technical Information             execution




Program execution under COHERENT is governed by the various forms
of the COHERENT system call  exec.  This call allows a process to
execute  another executable  file (load  module, as  described in
l.out.h).  The code, data and  stack of file replace those of the
requesting process.  The new stack contains the command arguments
and its environment, in the format given below.  Execution starts
at the entry point of file.

During a  successful exec, the system  deactivates profiling, and
resets any caught signals to SIG_DFL.

Every process  has a real-user id, an  effective-user id, a real-
group id, and an effective-group id, as described in getuid.  For
most load  modules, exec does not change  any of these.  However,
if the  file is marked with  the set user id or  set group id bit
(see stat), exec  sets the effective-user id (effective-group id)
of the process  to the user id (group id)  of the file owner.  In
effect, this changes the file access privilege level from that of
the  real id  to that  of the  effective id.   The owner  of file
should be  careful to limit its  abilities, to avoid compromising
file security.

exec initializes  the new stack of the process  to contain a list
of strings  which are command arguments.   execl, execle, and ex-
eclp specify arguments individually, as a NULL-terminated list of
arg parameters.  execv, execve, and execvp specify arguments as a
single NULL-terminated array argv of parameters.

The main routine of a C program is invoked in the following way:


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


argc is the number  of command arguments passed through exec, and
argv is an array of the  actual argument strings.  envp is an ar-
ray of strings that comprise the process environment.  By conven-
tion, these strings  are of the form variable=value, as described
in the Lexicon entry environ.  Typically, each variable is an ex-
ported shell variable with the given value.

execl and  execv simply pass  the old environment,  referenced by
the external  pointer environ.  execle and execve  pass a new en-
vironment env  explicitly.  execlp and execvp  search for file in
each of the directories indicated by the shell variable $PATH, in
the same way that the  shell searches for a command.  These calls
will execute a shell command file.

***** Files *****

/bbiinn/sshh -- To execute command files



COHERENT Lexicon                                           Page 1




execution             Technical Information             execution



***** See Also *****

environ,  execl(),  execle(),  execlp(), execv(),  execve(),  ex-
ecvp(), fork(), ioctl(), signal(), stat(), technical information

***** Diagnostics *****

None of the exec routines returns if successful.  Each returns -1
for errors,  such as if file is  nonexistent, not accessible with
execute permission, has  a bad format, or is too  large to fit in
memory.














































COHERENT Lexicon                                           Page 2


