summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-08-19 00:09:52 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-08-19 00:09:52 +0000
commitc8ea3fae0ce6003ef9d73b5beef568ecb24a4aad (patch)
tree828a717efe52d6fe3aaed2c609efed856c762eea /usr.sbin/pkg_add
parent826ccce5c32876da679bc20dc369e2ea1a823c00 (diff)
trap SIGINT so that tempdirs get removed.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Temp.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm
index 5c872694870..741e2ea221a 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.3 2004/08/06 07:51:17 espie Exp $
+# $OpenBSD: Temp.pm,v 1.4 2005/08/19 00:09:51 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -20,12 +20,24 @@ use warnings;
package OpenBSD::Temp;
use File::Temp;
+use File::Path;
+
our $tempbase = $ENV{'PKG_TMPDIR'} || '/var/tmp';
+my $dirs = [];
+
+$SIG{'INT'} = sub {
+ File::Path::rmtree($dirs);
+ $SIG{'INT'} = 'DEFAULT';
+ kill 'INT', $$;
+};
+
sub dir()
{
- return File::Temp::tempdir("pkginfo.XXXXXXXXXXX", DIR => $tempbase,
+ my $dir = File::Temp::tempdir("pkginfo.XXXXXXXXXXX", DIR => $tempbase,
CLEANUP => 1).'/';
+ push(@$dirs, $dir);
+ return $dir;
}
sub list($)