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

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.

主站蜘蛛池模板: 郁南县| 尼木县| 台前县| 巴中市| 琼海市| 万年县| 和平县| 五家渠市| 丰台区| 苍山县| 剑阁县| 福海县| 新丰县| 巴东县| 佛教| 论坛| 西林县| 长汀县| 清水河县| 石渠县| 寿宁县| 曲松县| 正蓝旗| 新津县| 丰镇市| 长丰县| 洛隆县| 平凉市| 冷水江市| 阿合奇县| 杨浦区| 丰镇市| 双辽市| 女性| 曲麻莱县| 清涧县| 信宜市| 台山市| 固安县| 凤冈县| 蚌埠市|