收到信息后将它们送到标准输出文件上。Р2、用 pipe( )创建一个管道文件,然后用fork( )创建两个生产进程和两个消费进程,它们之间通过pipe( )传递信息。Р四、部分参考代码Р1、#include <stdio.h>Р #include <unistd.h>Р #include <stdlib.h>Р#include <string.h>Рmain( )Р{int i,f_des[2];Р char message[3][BUFFSIZ]={“Start the test of pipe file”,”Test is going”,Р “Test ends”};Рif(pipe(f_des)==-1){printf(“pipe”);exit(2);}Рswitch(fork( ))Р{case -1:printf(“Fork”);exit(3);Р case 0:close(f_des[1]);Р for(i=0;i<3;i++)Р {if(read(f_des[0],message[i],BUFSIZ)!=-1) Р printf(“message received by child:[%s]\n”,message[i]);Р fflush(stdout);}Р else {printf(“Read Failed”);exit(4);}Р }Р break;Р default;Р close(f_des[0]);Р for(i=0;i<3;i++)Р {if(write(f_des[1],message[i],BUFSIZ)!=-1)Р { printf(“message sent by parent:[%s]\n”,message[i]);Р fflush(stdout);}Р else {printf(“write Failed”);exit(5);}Р }