- 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.
推薦閱讀
- Learning C# by Developing Games with Unity 2020
- 自己動手實現Lua:虛擬機、編譯器和標準庫
- Python高級編程
- Rust Cookbook
- Python 3網絡爬蟲實戰
- Android 應用案例開發大全(第3版)
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- 利用Python進行數據分析
- Multithreading in C# 5.0 Cookbook
- PHP+Ajax+jQuery網站開發項目式教程
- Internet of Things with ESP8266
- 小型編譯器設計實踐
- Java7程序設計入門經典
- Node.js 6.x Blueprints
- Python高性能編程(第2版)