EXEC Replacement Process image
On the creation of a process UNIX employs a unique approach that separates process creation from loading a new process image. The advantage is that there is more room to manage both operations. When we create a process, we typically replace the subprocess with a new process image, which can be done using the EXEC series function. Of course, the Exec series functions can also replace the current process.
EXEC Association Function Group
Include header file <unistd.h>
function uses the EXEC function to replace the current process with a new process. exec name is a complete series consisting of multiple correlation functions, header file <unistd.h>
Prototype
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 execvpe (const char *file, char *const argv[),
Char *const envp[]);
Parameters
The path parameter indicates that you want to start the program's name including the path name
The arg parameter represents the parameters that the startup program takes
Return value: Successfully return 0, failure return-1
The number of execl,execlp,execle (all with "L") is variable, and the argument ends with a null pointer.
The second argument for Execv, EXECVP, and EXECVPE is an array of strings that, when started, passes the arguments given in the argv array to the main
A function whose name contains the letter "P" searches the PATH environment variable to find the executable file for the new program. If the executable is not on path-defined paths, you must pass the absolute file name, including subdirectories, as a parameter to these functions.
A function with the last letter "E" of the first name can set the environment variable itself.
These functions are usually implemented with EXECVE, which is a common practice, not necessarily.
int Execve (const char *filename, char *const argv[], char *const envp[]);
Note that the first 6 functions are C library functions, and EXECVE is a system call.