11/3/71                                             SYS EXEC (II)





NAME            exec  --  execute a file



SYNOPSIS        sys     exec; name; args        / exec = 11.

                ...

          name: <...\0>

                ...

          args: arg1; arg2; ...; 0

          arg1: <...\0>

                ...



DESCRIPTION     exec overlays the calling process with the named

                file, then transfers to the beginning of the core

                image of the file.  The first argument to exec is

                a pointer to the name of the file to be executed.

                The second is the address of a list of pointers

                to arguments to be passed to the file.  Conven-

                tionally, the first argument is the name of the

                file.  Each pointer addresses a string terminated

                by a null byte.



                There can be no return from the file; the calling

                core image is lost.



                The program break is set from the executed file;

                see the format of a.out.



                Once the called file starts execution, the argu-

                ments are passed as follows.  The stack pointer

                points to the number of arguments.  Just above

                this number is a list of pointers to the argument

                strings.



                  sp->  nargs

                        arg1

                        ...

                        argn



                 arg1:  <arg1\0>

                        ...

                 argn:  <argn\0>



                The arguments are placed as high as possible in

                core: just below 60000(8).



                Files remain open across exec calls.  However,

                the illegal instruction, emt, quit, and interrupt

                trap specifications are reset to the standard

                values.  (See ilgins, cemt, quit, intr.)



                Each user has a real user ID and an effective

                (The real ID identifies the person using the sys-

                tem; the effective ID determines his access priv-

                ileges.)  exec changes the effective user ID to

                the owner of the executed file if the file has

                the "set-user-ID" mode.  The real user ID is not

                affected.



FILES           --



SEE ALSO        fork



DIAGNOSTICS     If the file cannot be read or if it is not exe-

                cutable, a return from exec constitutes the diag-

                nostic.  The error bit (c-bit) is set.



BUGS            --



OWNER           ken, dmr