Linux exec函数族
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://tuhao.blogbus.com/logs/22833492.html
extern char **environ;
int execl(const char* fullpath, const char* arg, ...);
int execlp(const char* file, const char* arg, ...);
int execle(const char* fullpath, const char* arg , ..., char* const envp[]);
int execv(const char* fullpath, char* const argv[]);
int execvp(const char* file, char* const argv[]);
int execve(const char* fullpath, const char* arg[] , char* const envp[]);
int execl(const char* fullpath, const char* arg, ....)
使用范例:execl(“/bin/ls”, ”ls”, ”-al”, NULL)
int execlp(const char* file, const char* arg, ....)
使用范例:execlp(“ls”, ”ls”, ”-al”, NULL)
int execle(const char* fullpath, const char* arg, ...., char* const envp[])
使用范例:execle(“/bin/ls”, ”ls”, ”-al”, NULL, environ)
int execv(const char * fullpath, char* const argv[])
使用范例:execle(“/bin/mkdir”, argv) // int main(int argc, char* argv[])
或
char* const p[] = {"a.out", "testDir", NULL};
execv("/bin/mkdir", p);
int execvp(const char* file, const char* arg, ....)
使用范例:execlp(“ls”, argv) // int main(int argc, char* argv[])
或
char* const p[] = {"a.out", "testDir", NULL};
execvp("mkdir", p);
int execve(const char* fullpath, const char* arg, ...., char* const envp[])
使用范例:execve(“/bin/ls”, argv, environ)
或
char* const p[] = {"a.out", "testDir", NULL};
execve("/bin/mkdir", p);