The
exec
Family of Calls

Name:
execvp()
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 in the file
file
, and passes the arguments
argv
to that invoked program. The OS will search for this file at the locations indicated in the PATH environmental variable, and, otherwise, in the current folder.
What libraries you must include:
#include <unistd.h> // Defines execvp().
Syntax:
int execvp (const char *file, char *const argv[]);
Description of arguments:
file
: the name of the file containing the program to run
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:
execvp ("my_uniq", newargv);
perror ("execvp"); /* execvp() returns only on error */
Other variations:
execve()
,
execv()
,
execle()
,
execl()
,
execlp()