version 1 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
EXEC |
|
|
2 |
!!!EXEC |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
FILES |
|
|
8 |
ERRORS |
|
|
9 |
SEE ALSO |
|
|
10 |
COMPATIBILITY |
|
|
11 |
CONFORMING TO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
execl, execlp, execle, execv, execvp - execute a file |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include __ |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
__extern char **environ;__ |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
__int execl( const char *__''path''__, const char |
|
|
27 |
*__''arg''__, ...); |
|
|
28 |
int execlp( const char *__''file''__, const char |
|
|
29 |
*__''arg''__, ...); |
|
|
30 |
int execle( const char *__''path''__, const char |
|
|
31 |
*__''arg'' __, ..., char * const__ |
|
|
32 |
''envp''__[[]); |
|
|
33 |
int execv( const char *__''path''__, char *const__ |
|
|
34 |
''argv''__[[]); |
|
|
35 |
int execvp( const char *__''file''__, char *const__ |
|
|
36 |
''argv''__[[]);__ |
|
|
37 |
!!DESCRIPTION |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
The __exec__ family of functions replaces the current |
|
|
41 |
process image with a new process image. The functions |
|
|
42 |
described in this manual page are front-ends for the |
|
|
43 |
function execve(2). (See the manual page for |
|
|
44 |
__execve__ for detailed information about the replacement |
|
|
45 |
of the current process.) |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
The initial argument for these functions is the pathname of |
|
|
49 |
a file which is to be executed. |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
The ''const char *arg'' and subsequent ellipses in the |
|
|
53 |
__execl__, __execlp__, and __execle__ functions can |
|
|
54 |
be thought of as ''arg0'', ''arg1'', ..., ''argn''. |
|
|
55 |
Together they describe a list of one or more pointers to |
|
|
56 |
null-terminated strings that represent the argument list |
|
|
57 |
available to the executed program. The first argument, by |
|
|
58 |
convention, should point to the file name associated with |
|
|
59 |
the file being executed. The list of arguments ''must'' |
|
|
60 |
be terminated by a __NULL__ pointer. |
|
|
61 |
|
|
|
62 |
|
|
|
63 |
The __execv__ and __execvp__ functions provide an |
|
|
64 |
array of pointers to null-terminated strings that represent |
|
|
65 |
the argument list available to the new program. The first |
|
|
66 |
argument, by convention, should point to the file name |
|
|
67 |
associated with the file being executed. The array of |
|
|
68 |
pointers ''must'' be terminated by a __NULL__ |
|
|
69 |
pointer. |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
The __execle__ function also specifies the environment of |
|
|
73 |
the executed process by following the __NULL__ pointer |
|
|
74 |
that terminates the list of arguments in the parameter list |
|
|
75 |
or the pointer to the argv array with an additional |
|
|
76 |
parameter. This additional parameter is an array of pointers |
|
|
77 |
to null-terminated strings and ''must'' be terminated by |
|
|
78 |
a __NULL__ pointer. The other functions take the |
|
|
79 |
environment for the new process image from the external |
|
|
80 |
variable ''environ'' in the current process. |
|
|
81 |
|
|
|
82 |
|
|
|
83 |
Some of these functions have special semantics. |
|
|
84 |
|
|
|
85 |
|
|
|
86 |
The functions __execlp__ and __execvp__ will duplicate |
|
|
87 |
the actions of the shell in searching for an executable file |
|
|
88 |
if the specified file name does not contain a slash (/) |
|
|
89 |
character. The search path is the path specified in the |
|
|
90 |
environment by the __PATH__ variable. If this variable |
|
|
91 |
isn't specified, the default path ``:/bin:/usr/bin'' is |
|
|
92 |
used. In addition, certain errors are treated |
|
|
93 |
specially. |
|
|
94 |
|
|
|
95 |
|
|
|
96 |
If permission is denied for a file (the attempted |
|
|
97 |
__execve__ returned __EACCES__), these functions will |
|
|
98 |
continue searching the rest of the search path. If no other |
|
|
99 |
file is found, however, they will return with the global |
|
|
100 |
variable ''errno'' set to __EACCES__. |
|
|
101 |
|
|
|
102 |
|
|
|
103 |
If the header of a file isn't recognized (the attempted |
|
|
104 |
__execve__ returned __ENOEXEC__), these functions will |
|
|
105 |
execute the shell with the path of the file as its first |
|
|
106 |
argument. (If this attempt fails, no further searching is |
|
|
107 |
done.) |
|
|
108 |
!!RETURN VALUE |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
If any of the __exec__ functions returns, an error will |
|
|
112 |
have occurred. The return value is -1, and the global |
|
|
113 |
variable ''errno'' will be set to indicate the |
|
|
114 |
error. |
|
|
115 |
!!FILES |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
''/bin/sh'' |
|
|
119 |
!!ERRORS |
|
|
120 |
|
|
|
121 |
|
|
|
122 |
All of these functions may fail and set ''errno'' for any |
|
|
123 |
of the errors specified for the library function |
|
|
124 |
execve(2). |
|
|
125 |
!!SEE ALSO |
|
|
126 |
|
|
|
127 |
|
|
|
128 |
sh(1), execve(2), fork(2), |
|
|
129 |
environ(5), ptrace(2) |
|
|
130 |
!!COMPATIBILITY |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
On some other systems the default path (used when the |
|
|
134 |
environment does not contain the variable __PATH__) has |
|
|
135 |
the current working directory listed after ''/bin'' and |
|
|
136 |
''/usr/bin'', as an anti-Trojan-horse measure. Linux uses |
|
|
137 |
here the traditional |
|
|
138 |
'' |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
The behavior of __execlp__ and __execvp__ when errors |
|
|
142 |
occur while attempting to execute the file is historic |
|
|
143 |
practice, but has not traditionally been documented and is |
|
|
144 |
not specified by the POSIX standard. BSD (and possibly other |
|
|
145 |
systems) do an automatic sleep and retry if ETXTBSY is |
|
|
146 |
encountered. Linux treats it as a hard error and returns |
|
|
147 |
immediately. |
|
|
148 |
|
|
|
149 |
|
|
|
150 |
Traditionally, the functions __execlp__ and __execvp__ |
|
|
151 |
ignored all errors except for the ones described above and |
|
|
152 |
__ENOMEM__ and __E2BIG__, upon which they returned. |
|
|
153 |
They now return if any error other than the ones described |
|
|
154 |
above occurs. |
|
|
155 |
!!CONFORMING TO |
|
|
156 |
|
|
|
157 |
|
|
|
158 |
__execl__, __execv__, __execle__, __execlp__ and |
|
|
159 |
__execvp__ conform to IEEE Std1003.1-88 |
|
|
160 |
(``POSIX.1''). |
|
|
161 |
---- |