I would like to use splice
to zero-copy data from STDIN_FILENO
to a file descriptor (which could be to a regular file, char or block device, FIFO, or anything that can be opened with open
). In order to use splice
, either the from file descriptor or to file descriptor must be the appropriate end of a pipe, so generally a pipe is created to serve as an intermediary buffer when the programmer wants to zero-copy data from non-pipe to non-pipe. However, if STDIN_FILENO
is already the read end of a pipe, then I could skip that step and attempt to splice directly from STDIN_FILENO
to the other file descriptor. Therefore, I would like to be able to determine whether STDIN_FILENO
is the read end of a pipe.
Is there a Linux system call that can determine whether STDIN_FILENO
is the read end of a pipe?
fstat
, and testedS_ISFIFO
: pastebin.com/ntauU2b5 . The result is thatS_ISFIFO
on thest_mode
for the read end of a pipe is TRUE. Your guess is correct, and it is actually per the POSIX standard: "S_ISFIFO(m) Test for a pipe or FIFO special file" (opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html) – Whelp