linux_module_learn/my_first_module/test/test_myfifo.c

27 lines
362 B
C
Raw Normal View History

2023-07-22 13:42:32 +08:00
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include<string.h>
int main()
{
int fd = 0;
int i = 0;
char w_buff[64] = {0};
fd = open("/dev/myfifo",O_RDWR);
while(1)
{
memset(w_buff,0,64);
sprintf(w_buff,"%d,",i++);
write(fd,w_buff,strlen(w_buff));
}
return 0;
}