I'm creating a scheduling software, i have hundreds of dataset described in text files. I'm using dirent.h with a loop to read the texts files, for each file i make a schedule and i append the result to another text file ( like cpu time, dataset name, tardiness ...), this file is common to all schedules.
I'm opening/closing the result file just once ( fopen()
before the loop, fclose()
after the loop when all the schedules are done).
I've no problem on Windows 7, but under linux, the file seems to be closed by the system due to a kind of timeout, I've just 9-10 dataset that are scheduled (~ 2 hours) and after it is stuck because it can't write into the result file :/
Does anyone already have this kind of trouble and found a solution?
Linux does not close the file automatically. Something is wrong in your code.
Try running your program using "strace" and identify where the
close()
happens.Open the
1.txt
file using a text editor (orless
) and see what your app is doing.