Skip Menu |

This queue is for tickets about the File-Temp CPAN distribution.

Report information
The Basics
Id: 11067
Status: resolved
Priority: 0/
Queue: File-Temp

People
Owner: Nobody in particular
Requestors: dmacks [...] netspace.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.14
Fixed in: 0.15



Subject: tempdir(CLEANUP=>1) broken when forking (was perlbug #33769)
[Moving from perlbug queue at request of module maintainer] [see http://rt.perl.org/rt3/Ticket/Display.html?id=33769 ] File::Temp::tempdir() implements the CLEANUP option by setting an END block to recursively delete the dir. If the process then forks, both parent and child have that END, and so it runs when either parent or child exit. That means when the child ends, it deletes the parent's tempdir. Test case: my $dir = File::Temp::tempdir(CLEANUP=>1); printf "start: %s\n", (-d $dir ? "Y" : "N"); if (not open(KID, "-|")) { printf "child: %s\n", (-d $dir ? "Y" : "N"); exit; } else { while (<KID>) { print; # spool child's STDOUT to parent's } printf "later: %s\n", (-d $dir ? "Y" : "N"); } gives me: start: Y child: Y later: N under File::Temp 0.14 (part of perl5.8.5 core, and latest in CPAN). Neither this effect (children can delete parent's or sibling's tempdir) nor the implementation of CLEANUP is documented in the POD. Proposed solution: the underlying _deferred_unlink() function could store the current pid along with the dirname, and the END would only delete if the pid were the same.
Should be fixed in version 0.15. Sorry for the delay and thanks for the reports.
Le Mar. Fév. 22 12:09:50 2005, TJENNESS a écrit : Show quoted text
> Should be fixed in version 0.15. Sorry for the delay and thanks for the > reports.
Actually, it has been fixed only for procedural interface. For object-oriented one, the old behaviour still applies. Just check the difference between the two test cases.
Download test
application/octet-stream 845b

Message body not shown because it is not plain text.

Download test-oo
application/octet-stream 868b

Message body not shown because it is not plain text.

Should be fixed in V0.19. The new File::Temp->newdir interface should also work.