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);

你可能感兴趣的:(Linux)