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

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.

主站蜘蛛池模板: 六枝特区| 庆城县| 介休市| 甘谷县| 内江市| 比如县| 什邡市| 青神县| 盐津县| 镇安县| 从化市| 即墨市| 电白县| 竹山县| 株洲市| 绍兴市| 丹东市| 虹口区| 唐海县| 元朗区| 赤水市| 宁德市| 土默特右旗| 邵东县| 四子王旗| 甘泉县| 威远县| 三都| 乐山市| 石柱| 博兴县| 高平市| 株洲县| 乐业县| 甘泉县| 平顺县| 思南县| 道真| 晋州市| 绩溪县| 万年县|