父进程程序:
#include
#include
#include
#include
int main(void)
{
char *args[]={"./two",NULL};
pid_t pid;
pid=fork();//复制程序
if(-1==pid){
printf("erron");
return -1;
}else if(pid==0)//子进程进入
{
printf("son,return fork: %d,ID :%d,father ID:%dn",pid,getpid(),getppid());
execve("./two",args,NULL);//two程序替代复制出的子进程
}else{
printf("father,return fork:%d,ID:%d,father ID:%dn",pid,getpid(),getppid());
}
return 0;
}
子进程程序:
#include
#include
int main(void)
{
printf("This is I first use this way to creat a procedure!");//输出指定字符
return 0;
}



