Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: How to clear named pipe to just have one line

by moritz (Cardinal)
on Feb 08, 2014 at 13:13 UTC ( #1073998=note: print w/replies, xml ) Need Help??

in reply to How to clear named pipe to just have one line

I don't think it's possible; if you read from a (named) pipe, its content is gone. So you can't read to check how much is in there.

Usually you don't need it either, since named pipes are buffered, and once the buffer is full, writing to it blocks. And, more to the point, you shouldn't even care how much is in the pipe; pipes are there to abstract that away.

What problem are you actually trying to solve? It could be an XY Problem.

  • Comment on Re: How to clear named pipe to just have one line

Replies are listed 'Best First'.
Re^2: How to clear named pipe to just have one line
by techman2006 (Beadle) on Feb 08, 2014 at 13:22 UTC

    Basically there are two unrelated processes say P1 (A C program) and P2(a Perl script). Now P2 is running and is output some data to stdout. Now P1 will come at regular interval to read such data.

    As these are unrelated processes. So I was thinking to use named pipe. Now process P1 want to read only one line which is output from process P2. As it continuously generates output we want to truncate the data so that process P1 don't read redundant data.

    Any thoughts how to solve this problem.

        As process P1 is an server which is multithread and one of thread will try to read status from process P2. So process P1 will not have way to capture stdout of process P2.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073998]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2017-09-21 02:19 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (241 votes). Check out past polls.