#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include<stdlib.h> int main(int argc , char **argv) { int id; id=fork(); if(id<0) { printf("fork error\n"); } else if(id==0) { printf("I'm in child process\n"); while(1) {printf("雷江涛ffffffffffffffffffffffffffffffffffffff\n"); exit(0);//exit函数只会结束一个进程,而不是结束一个程序, //如果加上exit这个子进程最多只能被执行一次就结束了 } } else { printf("I'm in parent process\n"); while(1) printf("近平是伟大的陕西人\n"); } return 0; }