What you want is unbuffered reading. Assuming you can't just switch to read () calls, open the device, and then set the stream to unbuffered mode. This has the added benefit of not having to close the stream when you are done. Just rewind it and start reading again.
FILE *f = fopen("/proc/net/dev", "r");
setvbuf(f, NULL, _IONBF, 0);
while (running)
{
rewind(f);
...do your reading...
}
source
share