1EXEC(3)                    Linux Programmer's Manual                   EXEC(3)
2
3
4

NAME

6       execl, execlp, execle, execv, execvp, execvpe - execute a file
7

SYNOPSIS

9       #include <unistd.h>
10
11       extern char **environ;
12
13       int execl(const char *pathname, const char *arg, ...
14                       /* (char  *) NULL */);
15       int execlp(const char *file, const char *arg, ...
16                       /* (char  *) NULL */);
17       int execle(const char *pathname, const char *arg, ...
18                       /*, (char *) NULL, char *const envp[] */);
19       int execv(const char *pathname, char *const argv[]);
20       int execvp(const char *file, char *const argv[]);
21       int execvpe(const char *file, char *const argv[],
22                       char *const envp[]);
23
24   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26       execvpe(): _GNU_SOURCE
27

DESCRIPTION

29       The  exec() family of functions replaces the current process image with
30       a new process image.  The functions described in this manual  page  are
31       layered  on  top  of execve(2).  (See the manual page for execve(2) for
32       further details about the replacement of the current process image.)
33
34       The initial argument for these functions is the name of a file that  is
35       to be executed.
36
37       The  functions can be grouped based on the letters following the "exec"
38       prefix.
39
40   l - execl(), execlp(), execle()
41       The const char *arg and subsequent ellipses can be thought of as  arg0,
42       arg1, ..., argn.  Together they describe a list of one or more pointers
43       to null-terminated strings that represent the argument  list  available
44       to  the  executed  program.   The first argument, by convention, should
45       point to the filename associated with the  file  being  executed.   The
46       list  of  arguments  must  be  terminated by a null pointer, and, since
47       these are variadic functions, this pointer must be cast (char *) NULL.
48
49       By contrast with the 'l' functions, the 'v' functions  (below)  specify
50       the command-line arguments of the executed program as a vector.
51
52   v - execv(), execvp(), execvpe()
53       The  char *const argv[] argument is an array of pointers to null-termi‐
54       nated strings that represent the argument list  available  to  the  new
55       program.   The first argument, by convention, should point to the file‐
56       name associated with the file being executed.  The  array  of  pointers
57       must be terminated by a null pointer.
58
59   e - execle(), execvpe()
60       The  environment of the caller is specified via the argument envp.  The
61       envp argument is an array of pointers to  null-terminated  strings  and
62       must be terminated by a null pointer.
63
64       All  other  exec()  functions  (which do not include 'e' in the suffix)
65       take the environment for the new process image from the external  vari‐
66       able environ in the calling process.
67
68   p - execlp(), execvp(), execvpe()
69       These  functions duplicate the actions of the shell in searching for an
70       executable file if the specified filename does not contain a slash  (/)
71       character.  The file is sought in the colon-separated list of directory
72       pathnames specified in the PATH environment variable.  If this variable
73       isn't  defined,