Hello - I need to create a utility using C/C++ to parse information from a XML audit log file that is continuously being appended by a separate process
I need to read the information in and process it, then when I reach the EOF I need to wait/monitor for more content to be added to the file and read/process the new information.
The code snippet below shows my initial approach -- the issue is that once the EOF is reached and it goes into the sleep loop, it does not pick up any additions to the file.
I did find a posting about this topic on the Java board, but it's old -- and I'm much less savvy with C/C++ than I am with Java.
Any suggestions would be appreciated :)
while(true){
if(inputStream.read(&mChar,1)) { // I tried using getline() here too...
// read the characters
} else {
// backup over the EOF character - not sure if this is necessary...
inputStream.unget(); // I tried doing a putback() here too...
sleep(10);
}
// run until interrupt is caught by sighandler...
}