The
exec
Family of Calls

Name:
execv()
System call or function: Function Links: Online Manual | Course Packet
What it does: Replaces the code of the program that calls it with a new code at location
path
, and passes the arguments
argv
to that invoked program.
What libraries you must include:
#include <unistd.h> // Defines execv().
Syntax:
int execv (const char *path, char *const argv[]);
Description of arguments:
path
: the location on disk where the code of the program you want to call is stored
argv
: an array of command-line argument strings that will be passed to the new program
What type it returns:
int
On success: It doesn't return: instead, the current program is replaced by the new program.
On failure:
-1
If failure, does it set
errno
?
Yes
Quick example:
execv ("/bin/ls", newargv);
perror ("execv"); /* execv() returns only on error */
Other variations:
execve()
,
execvp()
,
execle()
,
execl()
,
execlp()