summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Temp.pm35
1 files changed, 28 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm
index 741e2ea221a..e04d08823fe 100644
--- a/usr.sbin/pkg_add/OpenBSD/Temp.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Temp.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Temp.pm,v 1.4 2005/08/19 00:09:51 espie Exp $
+# $OpenBSD: Temp.pm,v 1.5 2005/08/21 18:38:17 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -26,17 +26,38 @@ our $tempbase = $ENV{'PKG_TMPDIR'} || '/var/tmp';
my $dirs = [];
-$SIG{'INT'} = sub {
+my $handler = sub {
+ my ($sig) = @_;
File::Path::rmtree($dirs);
- $SIG{'INT'} = 'DEFAULT';
- kill 'INT', $$;
+ $SIG{$sig} = 'DEFAULT';
+ kill $sig, $$;
};
+$SIG{'INT'} = $handler;
+$SIG{'QUIT'} = $handler;
+$SIG{'HUP'} = $handler;
+$SIG{'KILL'} = $handler;
+$SIG{'TERM'} = $handler;
+
sub dir()
{
- my $dir = File::Temp::tempdir("pkginfo.XXXXXXXXXXX", DIR => $tempbase,
- CLEANUP => 1).'/';
- push(@$dirs, $dir);
+ my $caught;
+ my $h = sub { $caught = shift; };
+ my $dir;
+
+ {
+ local $SIG{'INT'} = $h;
+ local $SIG{'QUIT'} = $h;
+ local $SIG{'HUP'} = $h;
+ local $SIG{'KILL'} = $h;
+ local $SIG{'TERM'} = $h;
+ $dir = File::Temp::tempdir("pkginfo.XXXXXXXXXXX",
+ DIR => $tempbase, CLEANUP => 1).'/';
+ push(@$dirs, $dir);
+ }
+ if (defined $caught) {
+ kill $caught, $$;
+ }
return $dir;
}