1. Introduction
In Linux, there is no exec () function, exec refers to a set of functions, a total of 6, respectively:
#include <unistd.h>
extern char **environ;
int execl (const char *path, const char *arg, ...);
int EXECLP (const char *file, const char *arg, ...);
int execle (const char *path, const char *arg, ..., char * const envp[]);
int execv (const char *path, char *const argv[]);
int EXECVP (const char *file, char *const argv[]);
int Execve (const char *path, char *const argv[], char *const envp[]);
Detailed definition:
EXECL (execution file)
Related functions
Fork,execle,execlp,execv,execve,execvp
Table header File
#include <unistd.h>
Defining functions
int execl (const char * path,const char * arg,....);
Function description
The EXECL () is used to execute the path of the file represented by the parameter path string, and the next argument represents the passing of the past argv (0), argv[1] When the file is executed ..., and the last argument must end with a null pointer (NULL).
return value
If the execution succeeds, the function does not return, and the execution failure returns 1 directly, and the reason for failure is in errno.
Example
#include <unistd.h>
Main ()
{
Execl ("/bin/ls", "ls", "-al", "/etc/passwd", (char *) 0);
}
Perform
/* Execute/BIN/LS-AL/ETC/PASSWD * *
-rw-r--r--1 root 705 Sep 3 13:52/etc/passwd
EXECLP (find files from the PATH environment variable and execute)
Related functions
Fork,execl,execle,execv,execve,execvp