On Thu, 15 Jan 2009, Ken Williams wrote:
> On Wed, Jan 14, 2009 at 7:12 PM, Eric Wilhelm
> >  do {unlink($file) and last; -e $file and die $!;
> >   warn "cannot unlink $file\n"; sleep 1; } for(1..20);
> 
> I'm not sure what we're talking about.  Is it "1 while unlink $f"?
> 
> If so, see this text from perlport.pod:
> 
>        Don't assume that a single "unlink" completely gets rid of the file:
>        some filesystems (most notably the ones in VMS) have versioned
>        filesystems, and unlink() removes only the most recent one (it doesn't
>        remove all the versions because by default the native tools on those
>        platforms remove just the most recent version, too).  The portable
>        idiom to remove all the versions of a file is
> 
>            1 while unlink "file";

That issue is unrelated to the current problem on Windows. On Windows
unlink($file) may return "1" but the file may continue to exist if
another process still holds an open handle to it (it must have opened it
with the FILE_SHARE_DELETE sharing mode; otherwise the unlink() would
have failed). This in turn will prevent you from deleting the containing
directory even after all contained files have allegedly been deleted.

This can happen when a virus scanner is checking the file while it is
being deleted.

Cheers,
-Jan


Reply via email to