# includestdio.h>
#includestdlib.h>
#includeunistd.h>
#includefcntl.h>
#includesys/types.h>
#includesys/stat.h>
#includestring.h>
int main()
{
pid_t id=fork();
if(id==0)
{
printf("child is running\n");
sleep(1);
char* env[]={"MYENV=/A/B/C/D/AAAA",NULL};
char* argv[]={"ls","-l","-n","-i",NULL};
// execl("/bin/ls","ls","-l","-n","-i",NULL);
// execlp("ls","ls","-l","-n","-i",NULL);
// execv("/bin/ls",argv);
// execvp("ls",argv);
// execle("./myenv","myenv",NULL,env);
execve("./myenv",argv,env);
printf("child id done\n"); //exec成功的话不执行此语句
exit(1);
}
else
{
pid_t ret=waitpid(id, NULL,0);
if(ret>0)
{
printf("father wait success\n"); }
else{
printf("child quit not normal\n");
} } return 0; }