exec族函数
执行其他程序
int execl(const char path,const char arg,…/(char)NULL*/);
执行程序的时候,使用PATH环境变量,执行的程序可以不用加路径
int execlp(const char file,const char arg,…/(char)NULL*/);
file要执行的程序
arg参数列表,最后需要一个NULL作为结尾
返回值:只有失败才返回
execl.c
#include<stdio.h>
#include<unistd.h>
int main()
{
//execlp("ls","ls","-l","--color=auto",NULL);
execl("/bin/ls","ls","-l","--color=auto",NULL);
//不需要判断返回值
perror("exec err");
printf("hello\n");
return 0;
}
3440

被折叠的 条评论
为什么被折叠?



