Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1073998]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2023-02-04 02:18 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (30 votes). Check out past polls.