1 .\" $NetBSD: exec.3,v 1.26 2014/09/27 16:42:07 wiz Exp $
3 .\" Copyright (c) 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)exec.3 8.3 (Berkeley) 1/24/94
32 .Dd September 26, 2014
47 .Vt extern char **environ;
49 .Fn execl "const char *path" "const char *arg" ...
51 .Fn execlp "const char *file" "const char *arg" ...
53 .Fn execlpe "const char *path" "const char *arg" ... "char *const envp[]"
55 .Fn execle "const char *path" "const char *arg" ... "char *const envp[]"
57 .Fn exect "const char *path" "char *const argv[]" "char *const envp[]"
59 .Fn execv "const char *path" "char *const argv[]"
61 .Fn execvp "const char *file" "char *const argv[]"
63 .Fn execvpe "const char *file" "char *const argv[]" "char *const envp[]"
67 family of functions replaces the current process image with a
69 The functions described in this manual page are front-ends for the function
71 (See the manual page for
73 for detailed information about the replacement of the current process.
76 manual page provides detailed information about the execution of
79 The initial argument for these functions is the pathname of a file which
84 and subsequent ellipses in the
90 functions can be thought of as
95 Together they describe a list of one or more pointers to NUL-terminated
96 strings that represent the argument list available to the executed program.
97 The first argument, by convention, should point to the file name associated
98 with the file being executed.
111 functions provide an array of pointers to NUL-terminated strings that
112 represent the argument list available to the new program.
113 The first argument, by convention, should point to the file name associated
114 with the file being executed.
115 The array of pointers
127 functions also specify the environment of the executed process by following
130 pointer that terminates the list of arguments in the parameter list
131 or the pointer to the argv array with an additional parameter.
132 This additional parameter is an array of pointers to NUL-terminated strings
138 The other functions take the environment for the new process image from the
141 in the current process.
143 Some of these functions have special semantics.
151 will duplicate the actions of the shell in searching for an executable file
152 if the specified file name does not contain a slash
155 The search path is the path specified in the environment by the
158 If this variable isn't specified,
162 is used instead, its value being:
163 .Pa /usr/bin:/bin:/usr/pkg/bin:/usr/local/bin .
164 In addition, certain errors are treated specially.
166 If permission is denied for a file (the attempted
170 these functions will continue searching the rest of
172 If no other file is found, however, they will return with the global variable
177 If the header of a file isn't recognized (the attempted
181 these functions will execute the shell with the path of
182 the file as its first argument.
183 (If this attempt fails, no further searching is done.)
185 If the file is currently busy (the attempted
189 these functions will sleep for several seconds,
190 periodically re-attempting to execute the file.
194 executes a file with the program tracing facilities enabled (see
199 functions returns, an error will have occurred.
200 The return value is \-1, and the global variable
202 will be set to indicate the error.
204 .Bl -tag -width /bin/sh -compact
209 Historically, the default path for the
216 .Dq Pa :/bin:/usr/bin .
217 This was changed to improve security and behaviour.
225 when errors occur while attempting to execute the file is historic
226 practice, but has not traditionally been documented and is not specified
231 Traditionally, the functions
237 ignored all errors except for the ones described above and
241 upon which they returned.
242 They now return if any error other than the ones described above occurs.
253 for any of the errors specified for the library functions
263 for any of the errors specified for the library function
284 function appeared first in QNX and the
286 function exists on both