----- Original Message -----
From: "Sisyphus" <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>
Sent: Wednesday, June 11, 2003 3:00 AM
Subject: Re: The pp-built executable's temporary directory.


> On Tue, Jun 10, 2003 at 08:33:20PM +1000, Sisyphus wrote:
> > I believe that since the temp file is a dll, there is no way it can be
> > removed until the exe has terminated. Am I correct ?
>
> Theoretically on WinNT one can create a file using the proper
> O_TEMPORARY Fcntl flag to mark it to be deleted on termination,
> and File::Temp indeed seem to use it.  I am not sure why it
> does not get cleaned properly though. :-(
>
> /Autrijus/

I ran the following script based on the File::Temp documentation.

  use File::Temp qw/ tempfile tempdir /;
  use warnings;

 $dir = tempdir( CLEANUP => 1 );
 ($fh, $filename) = tempfile( DIR => $dir );
 ($fh, $filename) = tempfile( DIR => $dir);
 ($fh, $filename) = tempfile( SUFFIX => '.dat');

sleep(5);
__END__

I find that $dir gets cleaned up as soon as the script exits, but the '.dat'
file remains. (No warnings or errors are emitted.)

If I comment out the line that creates the '.dat' file then the second of
the 2 files that is created in $dir does *not* get cleaned up. Not only that
but I get the error:
Can't unlink file C:\DOCUME~1\ROBERT~1\LOCALS~1\Temp\DEXSuD5P52/2fDsSzFLb1:
Permission denied at D:/Perl/lib/File/Temp.pm line 850.

Consequently, because the temp directory is not empty it cannot be removed -
and I get another error message telling me so.

The relevant section of Temp.pm is:

 if (-d $dir) {
  rmtree($dir, $DEBUG, 1); # Line 850
 }

Then again, this script cleans up fine:

  use File::Temp qw/ tempfile tempdir /;
  use warnings;

 $dir = tempdir( CLEANUP => 1 );
 ($fh, $filename) = tempfile( DIR => $dir );
 ($fh, $filename) = tempfile( DIR => $dir);

undef($fh);
sleep(5);
__END__

Does that help anyone determine what's going on ?

Cheers,
Rob


Reply via email to