I haven't tested this code but I'm wondering if the FIFO is simply setting the EOF bit when you read all available data. In that case, you might be able to do this:
std::ifstream fifo;
std::string line;
bool done = false;
/* code to open your FIFO */
while (!done)
{
while (std::getline(fifo, line))
{
/* do stuff with line */
}
if (fifo.eof())
{
fifo.reset(); // Clear the EOF bit to enable further reading
}
else
{
done = true;
}
}
If you read off the end of the FIFO, reset and wait for further data. If an error occurred, you're done. I got the idea for this from this website. You might have to also close and reopen the FIFO in the same block where you do the reset.