Home

execv

execv is a POSIX-compatible function in the exec family that replaces the current process image with a new executable. If successful, the running process becomes the new program, and the process ID remains unchanged; all prior code, data, and stack are replaced. The call does not return to the original program when the new program starts.

Signature and parameters: int execv(const char *path, char *const argv[]); path specifies the executable file to

Environment and behavior: execv uses the environment of the calling process; it does not take an environment

Path resolution and errors: execv does not search the PATH; the path must directly reference an executable

Related variants: The exec family includes execl, execle, execlp, execv, execve, and execvp. Variants with a 'p'

run,
which
may
be
absolute
or
relative.
argv
is
a
null-terminated
array
of
argument
strings
passed
to
the
new
program,
with
argv[0]
traditionally
containing
the
program
name.
pointer.
To
specify
a
custom
environment,
use
the
related
function
execve,
which
accepts
a
third
parameter
envp.
If
the
call
succeeds,
control
never
returns
to
the
caller;
on
failure,
it
returns
-1
and
sets
errno.
file.
The
kernel
performs
permission
checks
and
loads
the
program
into
memory.
Typical
errno
codes
on
failure
include
ENOENT
(no
such
file
or
directory)
and
EACCES
(permission
denied).
search
the
PATH,
while
those
with
'e'
allow
supplying
a
custom
environment;
variants
with
'l'
pass
a
list
of
arguments
and
those
with
'v'
use
an
argv
vector.