| #include <fcntl.h> |
| #include <stdio.h> |
| #include <sys/stat.h> |
| #include <unistd.h> |
| |
| int main(int argc, char **argv) { |
| int infd; |
| char buf[256]; |
| int len, wlen; |
| |
| int outfd = open("out", O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| if (outfd < 0) { |
| perror("open out"); |
| return 1; |
| } |
| |
| while (1) { |
| infd = open("/tmp/Fifo_bdt_tiaudio", O_RDONLY); |
| if (infd == -1) { |
| perror("open /tmp/Fifo_bdt_tiaudio"); |
| return 1; |
| } |
| |
| len = read(infd, buf, 256); |
| if (len != 0) { |
| printf("read %d bytes\n", len); |
| wlen = write(outfd, &buf, len); |
| if (len != wlen) { |
| printf("write error, wrote %d/%d\n", wlen, len); |
| } |
| } |
| close(infd); |
| } |
| return 0; |
| } |