I have a file that is constantly being appended to by syslog. I want to be able to fopen the file read all of the data out of it. remove the data that I read, close the file, wait a minute. do the whole thing over again. Having problems with the truncation part. I have looked at ftruncate but that requires I open the file instead of fopen. I can rewind to the top of the file but how do I write a EOF at that point. I can not close the file and reopen for write as syslog may have written extra data that I will lose. So Need a function to write EOF at the begining of the file. Thanks
Asked
Active
Viewed 835 times
0
-
possible duplicate of [Can we write an EOF character ourselves?](http://stackoverflow.com/questions/3061135/can-we-write-an-eof-character-ourselves) – musiKk May 02 '11 at 18:11
-
In what language? It is hard to answer API questions without knowing which API? – Raedwald Jul 11 '13 at 19:16
1 Answers
0
Log rotation may be a solution for you. Rename the file before you read it. That way, syslog can write to a new file and you don't have to worry about missing new data.

Emil Vikström
- 90,431
- 16
- 141
- 175