fi1.c

来自「Linux大学上机源码学习」· C语言 代码 · 共 21 行

C
21
字号
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#define FIFO_FILE "myfifo"int main(){ int fifo_fd,n,total_byte=0;  char readbuf[4096+1];  mkfifo(FIFO_FILE,0666);  fifo_fd=open(FIFO_FILE,O_RDONLY);  while((n=read(fifo_fd,readbuf,4096))>0){     printf("%d received %d bype\n",getpid(),n);     total_byte+=n;  }  close(fifo_fd);  printf("Process %d received %d bytes then finished\n",getpid(),total_byte);  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?