Ok so this was a weird one, we where using unlink in perl and it was returning success yet the file still exists, so what gives?
After much hunting and digging it turned out to be a nice little gotcha about the way unlink works under cygwin and hence is inherited by their perl implementation.
The basic crux is that in order to be a unix link as possible cygwin makes use of the delete on close function within windows to attempt to delete files that are shared locked by other applications. The result is that even though the file is reported as deleted it is only marked as pending deletion and will only actually be deleted when the last the shared lock counter reaches zero.
Unfortunately its easy for this to fail if the other locking application makes a change to the file the delete request will be silently discarded.
So there you have it, cygwin + perl + unlink = files delete some times, you have been warned.
For more info on the internals see the following: Re: Inconsistent behaviour when removing files on Cygwin
Leave a Reply
You must be logged in to post a comment.