tags:

views:

229

answers:

3

The situation I have is this: I'm redirecting input from one spot in my program to another through a pipe. However, it does not appear that this is working correctly, so I'd like to monitor what's going through the pipe.

Currently, I'm using dup2() to simply overwrite the stdin and stdout from the pipe.

How can I monitor what's going between the pipe?

+4  A: 

When I'm debugging a pipe in a bash script I'll often use the tee command to capture what's going through it without disrupting the flow.

There's a corresponding tee system call which looks like it might be useful for debugging pipes in C code, but I've never tried it.

timday
+1  A: 

A useful tool is the Pipe Viewer. I don't think it's of direct use in viewing the actual data going through your pipe, but would allow you to monitor progress and throughput. I think timday's answer is more what you are looking for, however.

nascent.cognition
A: 

You might also be interested in the pv tool (man page, review):

"pv - Pipe Viewer - is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion."

none