http://qs321.pair.com?node_id=761982


in reply to Deleting a File in Windows

deadpickle:

Another possibility: If another job has the file open, then the delete won't work. In my environment (running cygwin under Windows XP), I see this all the time. IIRC, cygwin has a background thread, so if you remove the file, it will actually be deleted after the other processes release the file.

As an illustration, create a simple text file called zanzibar.txt, and run the following program in a window.

#!/usr/bin/perl open INF, '<', 'zanzibar.txt' or die $!; sleep 300; close INF or die $!;

Then, in another window, delete the file. On my system, I see this:

roboticus@swill$ ls zanzibar.txt roboticus@swill$ rm zanzibar.txt roboticus@swill$ ls zanzibar.txt

If I wait five minutes and look again, it's gone:

roboticus@swill$ ls roboticus@swill$
...roboticus