develooper Front page | perl.perl5.porters | Postings from October 2005

Re: Inconsistent behaviour when removing files on Cygwin

Thread Previous
October 26, 2005 10:40
Re: Inconsistent behaviour when removing files on Cygwin
Message ID:
On 10/26/05, S├ębastien Aperghis-Tramoni <> wrote:
> Rafael Garcia-Suarez <> wrote:
> > S├ębastien Aperghis-Tramoni wrote:
> >
> > > [This] is wrong because if unlink() doesn't return an error, the file is
> > > supposed to be deleted. -f indeed says that the file is not present, but
> > > readdir() still lists it. Who should I believe?
> >
> > What says -e ?
> Same thing.
> > > I can't test but based on previous experiments, ActivePerl is more
> > > consistent as unlink() fails and the file is not removed.
> >
> > Cygwin and Win32 are whole different platforms. :)
> Yes, I know that Cygwin pretends to be a Unix but it actually inherit
> many constraints from Win32, as this hateful file locking. The problem
> here is that in the case of unlink(), Cygwin is inconsistent: it doesn't
> behave like a Unix program and doesn't behave like a Win32 program.

You said offlist that the file does get deleted when the file was
closed by your program. This means that cygwin is using
FILE_SHARE_DELETE when it opens files. Unfortunately Win32 perl doesnt
use this. Probably as older Win32 OS'es didnt support it which is the
same reason it isnt the default on Win32 OS'es that do support it. The
windows backwards compatibility fetish.

So it actually is possible to make Win32 perl behave the same as the
cygwin perl by making Win32 perl use FILE_SHARE_DELETE by default when
it can.  Without changes to the core you can get the same behaviour by
using Win32API::File::createFile() with the appropriate flags.


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About