- 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.
推薦閱讀
- Web程序設(shè)計(jì)及應(yīng)用
- Visual Basic編程:從基礎(chǔ)到實(shí)踐(第2版)
- Web Application Development with R Using Shiny(Second Edition)
- 單片機(jī)應(yīng)用技術(shù)
- PostgreSQL Replication(Second Edition)
- Python完全自學(xué)教程
- 焊接機(jī)器人系統(tǒng)操作、編程與維護(hù)
- Python忍者秘籍
- Learning OpenCV 3 Computer Vision with Python(Second Edition)
- 微服務(wù)架構(gòu)深度解析:原理、實(shí)踐與進(jìn)階
- FPGA嵌入式項(xiàng)目開發(fā)實(shí)戰(zhàn)
- Oracle實(shí)用教程
- Java 9 Programming By Example
- SignalR:Real-time Application Development(Second Edition)
- 愛上C語言:C KISS