- 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.
推薦閱讀
- Mastering AWS Lambda
- Java異步編程實戰
- 自制編譯器
- 騰訊iOS測試實踐
- 深入淺出Windows API程序設計:編程基礎篇
- HTML5游戲開發案例教程
- Learning Firefox OS Application Development
- 精通網絡視頻核心開發技術
- FLL+WRO樂高機器人競賽教程:機械、巡線與PID
- 單片機C語言程序設計實訓100例
- Learning Concurrency in Kotlin
- 新一代SDN:VMware NSX 網絡原理與實踐
- Django 3.0入門與實踐
- Advanced UFT 12 for Test Engineers Cookbook
- 微信公眾平臺服務號開發:揭秘九大高級接口