1exec(3) Library Functions Manual exec(3)
2
3
4
6 execl, execlp, execle, execv, execvp, execvpe - execute a file
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 extern char **environ;
15
16 int execl(const char *pathname, const char *arg, ...
17 /*, (char *) NULL */);
18 int execlp(const char *file, const char *arg, ...
19 /*, (char *) NULL */);
20 int execle(const char *pathname, const char *arg, ...
21 /*, (char *) NULL, char *const envp[] */);
22 int execv(const char *pathname, char *const argv[]);
23 int execvp(const char *file, char *const argv[]);
24 int execvpe(const char *file, char *const argv[], char *const envp[]);
25
26 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
27
28 execvpe():
29 _GNU_SOURCE
30
32 The exec() family of functions replaces the current process image with
33 a new process image. The functions described in this manual page are
34 layered on top of execve(2). (See the manual page for execve(2) for
35 further details about the replacement of the current process image.)
36
37 The initial argument for these functions is the name of a file that is
38 to be executed.
39
40 The functions can be grouped based on the letters following the "exec"
41 prefix.
42
43 l - execl(), execlp(), execle()
44 The const char *arg and subsequent ellipses can be thought of as arg0,
45 arg1, ..., argn. Together they describe a list of one or more pointers
46 to null-terminated strings that represent the argument list available
47 to the executed program. The first argument, by convention, should
48 point to the filename associated with the file being executed. The
49 list of arguments must be terminated by a null pointer, and, since
50 these are variadic functions, this pointer must be cast (char *) NULL.
51
52 By contrast with the 'l' functions, the 'v' functions (below) specify
53 the command-line arguments of the executed program as a vector.
54
55 v - execv(), execvp(), execvpe()
56 The char *const argv[] argument is an array of pointers to null-termi‐
57 nated strings that represent the argument list available to the new
58 program. The first argument, by convention, should point to the file‐
59 name associated with the file being executed. The array of pointers
60 must be terminated by a null pointer.
61
62 e - execle(), execvpe()
63 The environment of the new process image is specified via the argument
64 envp. The envp argument is an array of pointers to null-terminated
65 strings and must be terminated by a null pointer.
66
67 All other exec() functions (which do not include 'e' in the suffix)
68 take the environment for the new process image from the external vari‐
69 able environ in the calling process.
70
71 p - execlp(), execvp(), execvpe()
72 These functions duplicate the actions of the shell in searching for an
73 executable file if the specified filename does not contain a slash (/)
74 character. The file is sought in the colon-separated list of directory