, 1, # include,2 # include ,3 # include ,4 # include ,5 # include ,6 int main () ,7 { ,8,,,int pipefd [2]; ,9,,,如果(管(pipefd)==1) ,10,,,{ ,11,,,,perror(“管道”); ,12,,,,return 1; ,13,,,} ,14,,pid_t pid=fork (); ,15,,如果(pid<0) ,16,,,{ ,17岁,,,,,perror (“pid”); ,18岁,,,,,return 1; ,19岁,,,} ,20,,else 如果(pid==0) ,21,,,{ ,22岁,,,,,,关闭(pipefd [0]); ,23岁,,,,,,char buf[20]=岸峡游曳奖硎厩敢?年轻”; ,24岁,,,,,,,int 我=0; ,25岁,,,,,,,(i<10) ,26岁,,,,{ ,27,,,,,,写(pipefd[1],但,strlen (buf)); ,28岁,,,,,,睡眠(1); ,29岁,,,,,,我+ +; ,30岁,,,,} ,31岁,,,,,退出(1); ,32岁,,,} ,33岁,其他 ,34岁,,,{ ,35岁,,,,关闭(pipefd [1]); ,36,,,,char buf [200]; ,37岁,,,,int j=0; ,38岁,,,,,(j<10) ,39岁,,,,{ ,40岁,,,,memset (buf, ' \ 0 ', sizeof (buf)); ,41岁,,,,ssize_t 大?,读(pipefd[0],缓冲区,sizeof (buf)); ,42岁,,,,,,如果(size> 0) ,43岁,,,,,,printf (" % s \ n ",但); ,44岁,,,,,+ +; ,45岁,,,,} ,46岁,,,如果(waitpid (pid, NULL, 0)==pid) ,47岁,,,{ ,48岁,,,,,,printf (" wait 成功\ n "); ,49,,,,} ,50,,,} ,51岁,,return 0; ,52} , , ,Makefile: ,1管:pipe.c ,2,,,,,,,,gcc -o $ @ $ ^ 3.假:清洁 ,4清洁: ,5,,,,,,,,rm -f 管