fork
/*
* 多进程
* 时间
* 作者
*/
#include "../include/test01.h"
int test01_01(void){
int i, pid;
pid = fork();
printf("Forking...the pid: %d\n",pid);
for(i=0;i<5;i++ ){
printf("%d %d\n",i,getpid());
}
if(pid){
wait(NULL);
}
return 0;
}
int test01_02(void){
int pid;
pid = fork();
if(pid> 0){
printf("This is parent process: pid= %d\n",getpid());
wait(NULL);
}
if(pid == 0){
printf("This is child process: pid= %d\n",getpid());
execl("child_process"," ",NULL);
}
return 0;
}