/*-----------------------------------------------------*//*-----------------------exe.c-------------------------*/#include<stdio.h>#include<stdlib.h>#include<unistd.h>intmain(){if(execl("/home/pony/Desktop/test","test",NULL)<0){perror("execl");exit(-1);}printf("never be printed");return0;}/*---------------------------------*//*-----------test.c----------------*/#include<stdio.h>#include<stdlib.h>intmain(){printf("this is test.exe");gets();return0;}
调用shell
#include<stdio.h>#include<stdlib.h>#include<unistd.h>intmain(){if(execl("/bin/ls","ls",NULL)<0){perror("execl");exit(-1);}printf("never be printed");return0;}