summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBo Borgerson <gigabo@gmail.com>2008-04-28 10:30:22 -0400
committerJim Meyering <meyering@redhat.com>2008-04-28 17:28:58 +0200
commit2f55920ffc37474ac75eadfbe5d987eb0ea248cc (patch)
tree7c324ac4c3da8a56b0343831f7872c22a9a1e955 /tests
parentd6ec836387bc245a17e65f337452c9809bfcdeec (diff)
downloadcoreutils-2f55920ffc37474ac75eadfbe5d987eb0ea248cc.tar.xz
Only cleanup test dirs from the process that created them.
* tests/CuTmpdir.pm (import): Use closure around current PID to avoid cleanup races. Signed-off-by: Bo Borgerson <gigabo@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CuTmpdir.pm27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/CuTmpdir.pm b/tests/CuTmpdir.pm
index f9d2c00f0..84312a039 100644
--- a/tests/CuTmpdir.pm
+++ b/tests/CuTmpdir.pm
@@ -52,18 +52,6 @@ sub chmod_tree
find ($options, '.');
}
-sub on_sig_remove_tmpdir
-{
- my ($sig) = @_;
- if (defined $dir)
- {
- chmod_tree;
- File::Temp::cleanup;
- }
- $SIG{$sig} = 'DEFAULT';
- kill $sig, $$;
-}
-
sub import {
my $prefix = $_[1];
@@ -82,9 +70,22 @@ sub import {
or skip_test $prefix;
$prefix = $1;
+ my $original_pid = $$;
+
+ my $on_sig_remove_tmpdir = sub {
+ my ($sig) = @_;
+ if ($$ == $original_pid and defined $dir)
+ {
+ chmod_tree;
+ File::Temp::cleanup;
+ }
+ $SIG{$sig} = 'DEFAULT';
+ kill $sig, $$;
+ };
+
foreach my $sig (qw (INT TERM HUP))
{
- $SIG{$sig} = \&on_sig_remove_tmpdir;
+ $SIG{$sig} = $on_sig_remove_tmpdir;
}
$dir = File::Temp::tempdir("$prefix.tmp-XXXX", CLEANUP => 1 );