I want to redirect fifo to stdout and I read the document http://man7.org/linux/man-pages/man2/tee.2.html
It says tee(int fd_in, int fd_out,...)
but when I throw ffo fd into the 1st argument, it says an invalid error.
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
int main() {
int num = 0, fd;
char fifo[] = "/tmp/tmpfifo";
fd = open(fifo, O_RDONLY, 0644);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
}
num = tee(fd, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
if (num < 0) {
perror("tee");
exit(EXIT_FAILURE);
}
fprintf(stderr,"%d\n", num);
return 0;
}
The console shows: tee: invalid arguments. The first argument should be stdin?
source
share