3 exec, execl, _privates, _nprivates, _tos \- execute a file
11 int exec(char *name, char* argv[])
14 int execl(char *name, ...)
26 typedef struct Tos Tos;
28 struct { ... } prof; /* profiling data */
29 uvlong cyclefreq; /* cycle clock frequency */
30 vlong kcycles; /* kernel cycles */
31 vlong pcycles; /* process cycles (kernel + user) */
32 ulong pid; /* process id */
33 ulong clock; /* profiling clock */
34 /* top of stack is here */
44 overlay the calling process with the named file, then
45 transfer to the entry point of the image of the file.
48 points to the name of the file
49 to be executed; it must not be a directory, and the permissions
50 must allow the current user to execute it
53 It should also be a valid binary image, as defined in the
55 for the current machine architecture,
60 shell script must begin with
62 followed by the name of the program to interpret the file
63 and any initial arguments to that program, for example
70 When a C program is executed,
71 it is called as follows:
74 void main(int argc, char *argv[])
78 is a copy of the array of argument pointers passed to
80 that array must end in a null pointer, and
82 is the number of elements before the null pointer.
83 By convention, the first argument should be the name of
84 the program to be executed.
90 will be an array of the parameters that follow
92 in the call. The last argument to
94 must be a null pointer.
98 the arguments passed to the program
100 in the example above) will be the name of the file being
101 executed, any arguments on the
103 line, the name of the file again,
104 and finally the second and subsequent arguments given to the original
107 The result honors the two conventions of a program accepting as argument
108 a file to be interpreted and
110 naming the file being
113 Most attributes of the calling process are carried
114 into the result; in particular,
115 files remain open across
117 (except those opened with
120 into the open mode; see
122 and the working directory and environment
128 process has no notification handler
134 points to an array of
136 elements of per-process private data.
137 This storage is private for each process, even if the processes share data segments.
139 When the new program begins, the global pointer
141 is set to the address of a structure
142 that holds information
143 allowing accurate time keeping and clock reading in user space.
144 These data are updated by the kernel during of the life of the process,
149 If there is a user-space accessible fast clock (a processor
152 will be set to its frequency in Hz.
155 counts the number of cycles
156 this process has spent in kernel mode
157 (kernel and user mode).
159 is the current process's id.
161 is the user-profiling clock (see
163 Its time is measured in milliseconds but is updated at
164 a system-dependent lower rate.
165 This clock is typically used by the profiler but is available
168 The above conventions apply to C programs; the raw system
169 interface to the new image is as follows:
170 the word pointed to by the stack pointer is
172 the words beyond that are the zeroth and subsequent elements
175 followed by a terminating null pointer; and
176 the return register (e.g.
178 on the 68020) contains the address of the
182 .B /sys/src/libc/9syscall
184 .B /sys/src/libc/port/execl.c
190 If these functions fail, they return and set
192 There can be no return to the calling process from a successful
196 the calling image is lost.