This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unable to delete directory in Cygwin


Hi Gina,

While this logic works fine in the linux, the temporary directory does
not get deleted in cygwin.

Since this appears to be a cygwin specific problem, you really ought to post your question on their mailing list.



/* ldmain.c */
main()
{
my_function();
delete tmp_directory;//I have to delete the tmp_directory only here }


/* myfile.c */
my_function()
{
create tmp directory tmp_directory;
.
create intermediate files in the above directory; .
my_process_function(intermediate files);//processes the intermediate
files .
return;
}

Note - for good programming practice you ought to try to keep the creation and deletion of the directory in the same function. ie either create and delete it in main() or in my_function() but do not create it in a child function and then hope that the parent function will remember to delete it.


After debugging using gdb, I found that in cygwin, the intermediate
files still had some handlers open for it despite of reaching till
> the end of the main() function in linker. Due to this, the temporary
files get deleted only after exiting from the main. Hence as the
> temporary drectory is not empty till then, it cannot get deleted.

This is probably due to a difference in the behaviour of the unlink() system call between Linux and Cygwin. It may well not be a bug though. It may just be that two OS's have different behaviours.

Cheers
  Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]