Sunday, February 21, 2010

Programmer - read the last line of a fifo

Programmer Question

Here is the situation : Some process writes lines into a fifo file (created with mkfifo). At some point in my program, I want to read the last line in the fifo, and discard all the others. The procedure may block, only if there is less than one line in the fifo.



I can't come up with a clean way to do this, any ideas ?



EDIT : The writing process will never stop writing lines into the fifo, What I mean by the last line is the last by the time I read the fifo. It is not necessarily followed by a EOF.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails