- 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.
推薦閱讀
- C++程序設計教程
- R語言數據分析從入門到精通
- Learning Cython Programming
- Design Principles for Process:driven Architectures Using Oracle BPM and SOA Suite 12c
- Computer Vision for the Web
- C#完全自學教程
- 數據庫系統原理及MySQL應用教程
- Quarkus實踐指南:構建新一代的Kubernetes原生Java微服務
- 大模型RAG實戰:RAG原理、應用與系統構建
- Learning Docker Networking
- SQL Server on Linux
- 從零開始構建深度前饋神經網絡:Python+TensorFlow 2.x
- 3D Printing Designs:The Sun Puzzle
- Professional JavaScript
- Developer,Advocate!