Subject: | Temporary directory remains |
Problem:
Temporary directory for communicating parent/child processes remains after instance is
disposed.
"ext3" file system on Linux has limitation that a directory can have at most 31998
subdirectories. So this problem will cause a failure to create Parallel::ForkManager
instance.
Environment:
Parallel::ForkManager 1.03
File::Path 1.x (included in perl <= 5.8.8 as a core module)
$ corelist -a File::Path
File::Path was first released with perl 5.001
(snip)
5.008008 1.08
5.008009 2.07_02
5.009 1.06
5.009001 1.06
5.009002 1.06
5.009003 1.08 5.009004 1.08
5.009005 2.01
5.01 2.04
5.010000 2.04
How to repeat:
$ export TMPDIR=/tmp/my
$ mkdir $TMPDIR
$ rm -fr $TMPDIR/*
$ perl -MParallel::ForkManager -e 'my $pm=Parallel::ForkManager->new;'
$ ls $TMPDIR
reXAmJdvaD
Parallel::ForkManager call File::Path::remove_tree in DESTROY to cleanup temporary
directory.
But File::Path < 2.0 does not have "remove_tree" method, so temporary directory remains.
Suggest:
--- ForkManager.pm.orig 2013-03-06 18:26:19.000000000 +0900
+++ ForkManager.pm 2013-03-07 01:41:36.916228553 +0900
@@ -659,7 +659,8 @@
my ($self) = @_;
if ($self->{parent_pid} == $$ && -d $self->{tempdir}) {
- File::Path::remove_tree($self->{tempdir});
+ my $remove_tree = File::Path->can('remove_tree') || File::Path->can('rmtree');
+ $remove_tree->($self->{tempdir});
}
}