function definition:
int execl (const char *path, const char *arg, ...);
This function is user process operation, Linux is included in header file #include <unistd.h>
Function Description: path represents the file path of the operation, followed by an indeterminate argument list to pass past arguments when the file is executed, and the last parameter needs to be NULL to end.
A classic example:
1 #include <unistd.h>2main ()3{4 execl ("/bin/ls", "LS", "-al", "/etc/passwd", (char *)0); 5 }
However, the second parameter in the example is not passed in the past followed by/bin/ls, but instead overrides the name of the file that was passed in to be executed. But the file name to be executed in the first argument is already very clear, why pass in the second redundant parameter?
According to Apue's explanation: We set the first parameter (Argv[0]) to the filename component of the pathname, and some shells set this parameter to the full pathname, which is just a convention that we can set to any value.
So what is the effect of the second parameter? It will affect the process name and can be verified with ps-ef view.
execl function Parameter Problem