linux多进程代码

 

#include <iostream>
#include<unistd.h>
#include<sys/types.h>
using namespace std;
int main()
{
 int i;
 if (fork() == 0)
 {
  /* 子进程程序 */
  for (i = 1; i < 1000; i++)
   cout<<"子进程"<<i<<endl;
 }

 else
 {
  /* 父进程程序*/
  for (i = 1; i < 1000; i++)
   cout<<"父进程"<<i<<endl;
 }
 getchar();
 return 0;
}

原文地址:https://www.cnblogs.com/byfei/p/3112273.html