eexxeeccuuttiioonn -- Definition

Program execution  under COHERENT is  governed by the various  forms of the
COHERENT system call eexxeecc(). This  call allows a process to execute another
executable _f_i_l_e (or load module).  This is described in ccooffff.hh.

The code, data  and stack of _f_i_l_e 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 _f_i_l_e.

During a  successful call to eexxeecc(), the  system deactivates profiling, and
resets any caught signals to SSIIGG_DDFFLL.

Every process  has a real-user id, an  effective-user id, a saved-effective
user id; and a real-group  id, an effective-group id, and a saved-effective
group  id.   These identifiers  are  defined in  the  Lexicon entries  for,
respectively, sseettuuiidd() and sseettggiidd(). For most load modules, eexxeecc() does not
change any of  these.  However, if the _f_i_l_e is  marked with the set user id
or  set  group id  bit  (see  ssttaatt()), eexxeecc()  sets  the effective-user  id
(effective-group id) of  the process to the user id  (group id) of the _f_i_l_e
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 _f_i_l_e should be
careful to limit its abilities, to avoid compromising file security.

eexxeecc()  initializes the  new stack  of  the process  to contain  a list  of
strings,  which are  command arguments.   eexxeeccll(), eexxeeccllee(),  eexxeeccllpp(), and
eexxeeccllppee() specify arguments  individually, as a NULL-terminated list of _a_r_g
parameters.  eexxeeccvv(),  eexxeeccvvee(), eexxeeccvvpp(), and  eexxeeccvvppee() specify arguments
as a single NULL-terminated array aarrggvv of parameters.

The mmaaiinn() function of a C program is invoked in the following way:

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

aarrggcc is the number of command  arguments passed through eexxeecc(), and aarrggvv is
an array of the actual argument  strings.  eennvvpp is an array of strings that
comprise the process environment.   By convention, these strings are of the
form _v_a_r_i_a_b_l_e=_v_a_l_u_e, as  described in the Lexicon entry eennvviirroonn. Typically,
each _v_a_r_i_a_b_l_e is an eexxppoorrtted shell variable with the given _v_a_l_u_e.

eexxeeccll()  and eexxeeccvv()  simply pass  the old  environment, referenced  by the
external pointer eennvviirroonn.

eexxeeccllee(),  eexxeeccllppee(), eexxeeccvvee(),  and eexxeeccvvppee() pass  a new  environment _e_n_v
explicitly.

eexxeeccllpp(), eexxeeccllppee(), eexxeeccvvpp(), and eexxeeccvvppee() search for _f_i_l_e in each of the
directories indicated by the shell variable $PPAATTHH, in the same way that the
shell searches  for a command.   These calls execute a  shell command _f_i_l_e.
Note that  eexxeeccllppee() and  eexxeeccvvppee() search the  current PPAATTHH, not  the PPAATTHH
contained within the environment pointed to by _e_n_v.

_F_i_l_e_s
/bbiinn/sshh -- To execute command files

_S_e_e _A_l_s_o
eennvviirroonn, eexxeecc(), eexxeeccll(), eexxeeccllee(), eexxeeccllpp(), eexxeeccllppee(), eexxeeccvv(), eexxeeccvvee(),
eexxeeccvvpp(),  eexxeeccvvppee(),  ffoorrkk(),  iiooccttll(),  PPrrooggrraammmmiinngg  CCOOHHEERREENNTT,  ssiiggnnaall(),
ssttaatt(), xxaarrggss

_D_i_a_g_n_o_s_t_i_c_s
None of the eexxeecc() routines returns  if successful.  Each returns -1 for an
error,  such as  if _f_i_l_e  does not  exist, is  not accessible  with execute
permission, has a bad format, or is too large to fit in memory.

_N_o_t_e_s
Each eexxeecc()  routine now examines  the beginning of an  executable file for
the  token #!.  If found,  it invokes  the program named  on that  line and
passes it the rest of the  file.  For example, if you wish to ensure that a
given script  is executed  by the  by the Bourne  shell /bbiinn/sshh,  begin the
script with the line:

    #!/bin/sh
