From 74d6c42cdb2f044baf1cdcf329a9f4244b90468c Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Fri, 24 May 2002 05:26:48 +0000 Subject: [PATCH] Clean up after ctrl-c is received. --- debian/changelog | 2 ++ scripts/dpkg-source.pl | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 6e14ab03..0c84aab1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -93,6 +93,8 @@ dpkg (1.10) unstable; urgency=low * Drop upgrade compat stuff in dpkg postinst for ancient versions (over 5 years old) * Always set CLOEXEC on the lock fd. Closes: Bug#147872 + * Clean up tmp files when ctrl-c is sent to dpkg-source. Closes: + Bug#58653. -- Wichert Akkerman Mon, 20 Aug 2001 14:54:38 +0200 diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 66df8ff2..5645959e 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -24,6 +24,15 @@ require 'controllib.pl'; # Make sure patch doesn't get any funny ideas delete $ENV{'POSIXLY_CORRECT'}; +my @exit_handlers = (); +sub exit_handler { + &$_ foreach ( reverse @exit_handlers ); + exit(127); +} +$SIG{'INT'} = \&exit_handler; +$SIG{'HUP'} = \&exit_handler; +$SIG{'QUIT'} = \&exit_handler; + sub usageversion { print STDERR "Debian dpkg-source $version. Copyright (C) 1996 @@ -327,7 +336,9 @@ if ($opmode eq 'build') { $sourcestyle =~ m/[KP]/ || &error("orig dir \`$origdir' already exists, not overwriting,". " giving up; use -sA, -sK or -sP to override"); + push @exit_handlers, sub { erasedir($origdir) }; erasedir($origdir); + pop @exit_handlers; } elsif ($! != ENOENT) { &syserr("unable to check for existence of orig dir \`$origdir'"); } @@ -338,13 +349,14 @@ if ($opmode eq 'build') { # checktarsane($origtargz,$expectprefix); mkdir("$origtargz.tmp-nest",0755) || &syserr("unable to create \`$origtargz.tmp-nest'"); + push @exit_handlers, sub { erasedir("$origtargz.tmp-nest") }; extracttar($origtargz,"$origtargz.tmp-nest",$expectprefix); rename("$origtargz.tmp-nest/$expectprefix",$expectprefix) || &syserr("unable to rename \`$origtargz.tmp-nest/$expectprefix' to ". "\`$expectprefix'"); rmdir("$origtargz.tmp-nest") || &syserr("unable to remove \`$origtargz.tmp-nest'"); - + pop @exit_handlers; } if ($sourcestyle =~ m/[kpursKPUR]/) { -- 2.39.5