I can not find an example of how to read the data in fifo. In user mode, I create a fifo and record the data, here is an example:
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/socket.h> #include<arpa/inet.h> #include<unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include<pthread.h> #include <sys/stat.h> #define MAX_BUF 999999 int main() { int i; int fd,d=0; char * myfifo = "/tmp/myfifo3"; char buf[MAX_BUF],src[]="1234567890qwertyuiop",src2[2]="98"; if((mkfifo(myfifo, 0666)) == -1) { fprintf(stderr, "Невозможно создать fifo\n"); } else{mkfifo(myfifo, 0666);} fd = open(myfifo, O_WRONLY); for (i=99999999;i>0;i--){ if(fd = open(myfifo, O_WRONLY)== -1){ fprintf(stderr, "Невозможно открыть fifo\n"); }else { d=1+(int) (10.0*rand()/(RAND_MAX+1.0)); src[0]=src[d]; write(fd, src, sizeof(src)); close(fd); } } return 0; } And how to work with fifo in kernel linux?
-EAGAIN- Mike