官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 应城市| 鄂托克前旗| 昌乐县| 虹口区| 安远县| 平邑县| 荣成市| 奉贤区| 托克逊县| 浮山县| 防城港市| 太湖县| 繁峙县| 清水河县| 阜康市| 普定县| 余庆县| 兖州市| 万荣县| 新竹市| 文昌市| 出国| 紫金县| 怀安县| 衡山县| 丰原市| 岢岚县| 达拉特旗| 邹城市| 老河口市| 遂昌县| 正宁县| 康乐县| 六枝特区| 灵川县| 义马市| 青浦区| 临猗县| 阜城县| 色达县| 合川市|