Program Execution
- This is chapter 27, you should read it.
- execve
- unistd.h
- int execve(const char *filename, char *const argv[],
char *const envp[]);
- filename is the executable file you wish to run.
- This should be an binary file.
- Or a script starting with a structured comment
- It can be an absolute or relative path
- But not a ~ path, why?
- argv is an array of strings representing the command line arguments.
- envp is an array of strings representing the environment variable.
- Both should be null terminated.
- It should not return.
- Starting on page 612 is a list of what happens to attributes when fork and exec are called.
- This is 4 pages long.
- It also contains system commands to change these things.
- There is a set of library functions that make exec easier
- Man 3p exec
- int execl(const char *path, const char *arg0, ... /*, (char *)0 */);
- int execle(const char *path, const char *arg0, ... /*,
(char *)0, char *const envp[]*/);
- int execlp(const char *file, const char *arg0, ... /*, (char *)0 */);
- int execv(const char *path, char *const argv[]);
- int execve(const char *path, char *const argv[], char *const envp[]);
- int execvp(const char *file, char *const argv[]);
- int fexecve(int fd, char *const argv[], char *const envp[]);
- The path name is given for most
- lp and vp do not, they search for a file name in the PATH environment variable.
- *l take a long argument list.
- *v expect a vector for the argument list.
- *e specify the environment list, otherwise use the parent processes.