From 57040c624d95cac73018ab0c16076d8f4fc5f28e Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Tue, 7 Mar 2006 14:18:52 +0000 Subject: properly zap temporary file. --- usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 3 ++- usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'usr.sbin/pkg_add') diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 97de9b5e990..b0f6810056c 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.6 2006/03/07 14:00:21 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.7 2006/03/07 14:18:51 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie # @@ -362,6 +362,7 @@ sub pkg_copy my ($copy, $filename) = File::Temp::tempfile($template, DIR => $dir) or die "Can't write copy to cache"; chmod 0644, $filename; + $object->{tempname] = $filename; my $handler = sub { my ($sig) = @_; unlink $filename; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm index fbe09ebd058..febc41c95c4 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SCP.pm,v 1.4 2006/03/07 14:00:48 espie Exp $ +# $OpenBSD: SCP.pm,v 1.5 2006/03/07 14:18:51 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie # @@ -109,6 +109,9 @@ sub pkg_copy $SIG{'USR1'} = sub { close($in); + if (defined $object->{tempname}) { + unlink $object->{tempname}; + } kill USR1 => $object->{parent}; exit(1); }; @@ -182,7 +185,7 @@ sub close # XXX we have to make sure the grand-child is dead. if (defined $object->{pid2}) { my $received = 0; - local $SIG{'USR1'} = sub { print STDERR "Received USR1\n"; $received = 1; }; + local $SIG{'USR1'} = sub { $received = 1; }; kill USR1 => $object->{pid2}; while (!$received) { sleep 0.01; -- cgit v1.2.3