#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
int main()
{
pid_t pid;
pid=fork();
if(pid==-1)
{
perror("fork");
exit(1);
}
else if(pid==0)
{
execl("/bin/ls","ls","-l","./",NULL);
// 路径 参数 必须以空指针结尾
}
else
{
printf("\nin the parent process!");
}
return 0;
}
/*
execl()用来执行参数path字符串所代表的文件路径(绝对路径),第二个参数代表执行文件
时传递的argv,最后一个参数必须是空指针。
*/