1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-26 00:56:13 +02:00

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>
This commit is contained in:
Bo Borgerson
2008-04-28 10:30:22 -04:00
committed by Jim Meyering
parent d6ec836387
commit 2f55920ffc

View File

@@ -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 );