reader.c (438B)
1 #include <fcntl.h> 2 #include <stdio.h> 3 #include <sys/stat.h> 4 #include <unistd.h> 5 6 #define MAX_BUF 1024 7 8 int main() 9 { 10 int fd; 11 char * myfifo = "/tmp/myfifo"; 12 char buf[MAX_BUF]; 13 14 /* open, read, and display the message from the FIFO */ 15 fd = open(myfifo, O_RDONLY); 16 read(fd, buf, MAX_BUF); 17 printf("Received: %s\n", buf); 18 read(fd, buf, MAX_BUF); 19 printf("Received: %s\n", buf); 20 close(fd); 21 22 return 0; 23 }