Take the 2-minute tour ×

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.


share|improve this question

2 Answers 2

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


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.


share|improve this answer

You could try recv(..., MSG_PEEK) -- this should read from the pipe without removing the data from it (so the next read would return the same data). It won't necessarily tell you about all the data queued, just some of it.

share|improve this answer
Does recv() work on non-socket files? –  bdonlan Oct 13 '11 at 21:50
so, in general the data read from the pipe will be removed ? –  Chaitanya Jun 19 '13 at 16:55

Your Answer


