Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see how much data is queued up in a named pipe?

Tags:

c

linux

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

like image 705
riderchap Avatar asked Oct 13 '11 18:10

riderchap


People also ask

How much data can a named pipe store?

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).

What is LSOF pipe?

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.


1 Answers

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

like image 183
Zack Bloom Avatar answered Oct 05 '22 01:10

Zack Bloom