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

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.

主站蜘蛛池模板: 昌宁县| 铜川市| 依兰县| 石河子市| 台前县| 贞丰县| 永康市| 枝江市| 黄陵县| 伊金霍洛旗| 赞皇县| 汾阳市| 广德县| 天长市| 双峰县| 宾川县| 甘洛县| 沿河| 清水河县| 呼和浩特市| 乡宁县| 建始县| 安庆市| 凌源市| 望都县| 罗甸县| 阳山县| 夏津县| 海城市| 金阳县| 龙游县| 富平县| 苏州市| 吴堡县| 横峰县| 屏东市| 乾安县| 阿克苏市| 祁阳县| 张家川| 漳浦县|