In a Linux box, I have couple of processes writing to a named pipe and another one reading it. I am suspecting that my reader is not keeping up and there are lot of data queued up in the pipe.
Could anyone please tell me that, is there a way to check/see how much data is queued up in the pipe? Any Linux command or C API?
Thank you for your time.
--KS
Since Linux 2.6. 11, the pipe capacity is 16 pages (i.e., 65,536 bytes in a system with a page size of 4096 bytes).
lsof is a very powerful Linux command line tool. It ships with just about every Linux distribution and gives you a list of open files, sockets, and pipes. The most basic usage of the tool is to type the command name followed by the Return key, # lsof. This command should return a rather long list.
I don't think FIONREAD will work as FIONREAD is determined by the value returned by i_size_read which is stored in the inode as i_size. i_size is not used with pipes (which is why stat always returns 0 for a pipe's size).
http://lxr.free-electrons.com/source/include/linux/fs.h#L848
It should be possible to get the size by summing the len property of the buffers (i_node.i_pipe.bufs). It doesn't look like this value is exposed by stat or ioctl though.
https://github.com/mirrors/linux-2.6/blob/master/fs/pipe.c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With