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

Re: Inconsistent behaviour when removing files on Cygwin

Thread Previous
From:
demerphq
Date:
October 26, 2005 10:40
Subject:
Re: Inconsistent behaviour when removing files on Cygwin
Message ID:
9b18b3110510261039v5ea704ddv8f9cb348e4e305cc@mail.gmail.com
On 10/26/05, S├ębastien Aperghis-Tramoni <maddingue@free.fr> wrote:
> Rafael Garcia-Suarez <rgarciasuarez@mandriva.com> 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.

yves

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

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About