Name: execve()
|
System call or function: System Call |
Links: Online Manual | Course Packet |
What it does: Replaces the code of the program that calls execve() 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 execve().
|
Syntax: int execve (const char *path, char *const argv[], char *const envp[]);
|
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
envp : an array of pointers to strings of the form key=value, representing the environment of 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: execve ("/bin/ls", newargv, newenviron);
perror ("execve"); /* execve() returns only on error */
|
Other variations: execv() , execvp() , execle() , execl() , execlp()
|