Linux下面有自己的一套进程的API,其实思路大致上与Windows下是一样的,只不过调用的API不同罢了! 实现代码: #include<stdio.h> #include<sys/types.h> #include<sys/wait.h> #include<unistd.h> #include<stdlib.h> #include<sys/time.h> char* data[]={"12110704","20072856","fysjx",NULL}; //defination of time int state; long startTime=0; long endTime=0; long runTime=0; struct timeval tmStart; struct timeval tmEnd; void main(int argc,char* argv[]) { gettimeofday(&tmStart,NULL); printf("Start time is %ld sec and %ld usec./n",tmStart.tv_sec,tmStart.tv_usec); pid_t pid; pid=fork(); if(pid<0) { printf("Fork Failed!/n"); exit(-1); } else if(pid==0) { if(execv(argv[1],data)<0) { printf("execv error!/n"); exit(-1); } exit(0); } else if(pid>0) { wait(&state); gettimeofday(&tmEnd,NULL); printf("End time is %ld sec and %ld usec./n",tmEnd.tv_sec,tmEnd.tv_usec); runTime=(tmEnd.tv_sec-tmStart.tv_sec)*1000000+(tmEnd.tv_usec-tmStart.tv_usec); printf("runTime is %ld usec./n",runTime); exit(0); } } 测试程序的代码: #include<stdio.h> #include<sys/time.h> int main() { printf("CreateProcess_Linux_RunDemo starts up!/n"); printf("Press any key to continue!/n"); getchar(); printf("End CreateProcess_Linux_RunDemo!/n"); return 0; } 运行效果: