Release all open files and directories at exit forcefully in C
c, cygwin
Solution
If by "release" you mean "close", that will happen anyway. The C runtime and the operating system will take care of that for you. On process termination all resources the process had open will be closed off. It would be a very rare (and poor quality) environment that didn't do that.
Problem
I want to release all open files and directories forecefully my program has opened during its execution. I want to do this because I have a very big program and it opens many files and directories which I am not able to keep track. Is there any way to do it? means I want to retrieve a list of all open files and directories and close them at exit. I know registration of exit handlers using atexit() function. Can something be done with it? Edit: I have cygwin on windows. I want to do the above thing because my program's resources are not being automatically released. I have a directory which is created and then opened using opendir(). After my program finishes, when I try to delete that directory, it says "cant delete, being used by another program". But when I terminate explorer.exe and again restart, then only I am able to delete that directory. The problem is it is happening unevenly. I am able to delete some directories and not able to delete some.