- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 183字
- 2021-07-08 09:47:19
exec
At times creating a child process might not be useful, unless it runs a new program altogether: the exec family of calls serves precisely this purpose. exec replaces the existing program in a process with a new executable binary:
#include <unistd.h>
int execve(const char *filename, char *const argv[],
char *const envp[]);
The execve is the system call that executes the program binary file, passed as the first argument to it. The second and third arguments are null-terminated arrays of arguments and environment strings, to be passed to a new program as command-line arguments. This system call can also be invoked through various glibc (library) wrappers, which are found to be more convenient and flexible:
#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 *constargv[]);
int execvp(const char *file, char *constargv[]);
int execvpe(const char *file, char *const argv[],
char *const envp[]);
Command-line user-interface programs such as shell use the exec interface to launch user-requested program binaries.
推薦閱讀
- AngularJS入門與進階
- 深入理解Bootstrap
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- 基于Swift語言的iOS App 商業實戰教程
- Python機器學習經典實例
- Serverless架構
- JavaScript入門經典
- Teaching with Google Classroom
- C語言程序設計教程
- Windows Phone 7.5:Building Location-aware Applications
- Mastering Python Design Patterns
- Image Processing with ImageJ
- Java EE項目應用開發
- Java語言程序設計實用教程(第2版)
- Clojure Data Structures and Algorithms Cookbook