Because of circumstances this is harder then it you would think.
I need to output to a file a data-stream coming from both internal fprintf statements and method's provided by a class.
that's not the hard part
but the program runs continually and while it's running a perl program is accessing the output, formating it and printing the data to the screen. I would also love for the perl program to be able to write to the file also.
Basically i have everything working. but on longer events steams OS locks the LogFile( i think ). I get the error and the program terminates.
I tryed only opening the file once and jsut fflush ing it. but what happens is when the perl program opens the file the C++ program loose the link to the file.
this is the output look
gFile() checks tosee if a lockfile exists. When the lockfile is deleted the program self-terminates.
CODE
// get first event... note this times out turning event into a NULL so you need to check later before outputing
struct inotify_event * event = inotifytools_next_event( 1 );
// while the lock file exists
while (gFile()) {
// this checks to make sure event is valid and prints
if (event) {
logFile = fopen(LOG_PATH, "a+");
if (logFile == NULL)
{
printf("gnoitfy:ERROR: LogFile Failed to Open. Terminating program\n");
exit(-1);
}
gPrint(logFile, event);
fclose(logFile);
}
// and get all corisponding events
event = inotifytools_next_event( 1 );
}
is there another way to do this?
can (instead of opining and closing can i re-link?)
the OS is Linux Kernel 2.6
the events can happen unto 30 times a second