Data queued in a named pipe.
Is there any way to find out how much data is queued in/written to a POSIX named pipe?
Thanks, Abhishek |
Other than reading the pipe, not that I know of.
When using sockets (for example, a socket pair created using socketpair(2)), one can use recv(descriptor,buffer,buffersize,MSG_NOWAIT|MSG_PEEK) to read but not consume already buffered data from the socket. It will not work with named pipes, however; only with sockets. |
Thank you for the helpful reply. For the problem I had at hand I only needed to know when the pipe is empty, so the reader can stop reading. After your conformation and going through the manpage again I guess a call to read(int fildes, void *buf, size_t nbyte) is enough for that.
But just out of curiosity and for possible utility, is there a way to peek into the underlying kernel data structures to find out the fifo size, if anyone knows that? |
Quote:
Quote:
An userspace application may adjust the pipe capacity freely between one page (sysconf(_SC_PAGESIZE) bytes) and /proc/sys/fs/pipe-size-max bytes. |
All times are GMT -5. The time now is 03:36 PM. |