r6698 - /scripts/qa/versioncheck2.pl

tincho-guest at users.alioth.debian.org tincho-guest at users.alioth.debian.org
Thu Aug 16 03:20:32 UTC 2007


Author: tincho-guest
Date: Thu Aug 16 03:20:32 2007
New Revision: 6698

URL: http://svn.debian.org/wsvn/?sc=1&rev=6698
Log:
Added signal handlers to remove the lockfile

Modified:
    scripts/qa/versioncheck2.pl

Modified: scripts/qa/versioncheck2.pl
URL: http://svn.debian.org/wsvn/scripts/qa/versioncheck2.pl?rev=6698&op=diff
==============================================================================
--- scripts/qa/versioncheck2.pl (original)
+++ scripts/qa/versioncheck2.pl Thu Aug 16 03:20:32 2007
@@ -61,7 +61,9 @@
         die("Other instance of $0 is running!\n");
     }
 }
-$SIG{__DIE__} = sub { debugmsg("Removing lockfile...\n"); unlink $lockfile };
+$SIG{HUP} = $SIG{INT} = $SIG{QUIT} = \&sighandler;
+$SIG{SEGV} = $SIG{PIPE} = $SIG{TERM} = \&sighandler;
+$SIG{__DIE__} = \&diehandler;
 open(LOCK, ">", $lockfile) or die $!;
 close(LOCK) or die $!;
 
@@ -73,6 +75,23 @@
 debugmsg( "CPAN mirror is $CPAN_MIRROR\n" );
 debugmsg( "The cache is in $CACHEDIR\n" );
 
+sub diehandler
+{
+    die @_ if($^S); # eval
+    debugmsg("Removing lockfile...\n");
+    unlink $lockfile;
+    die @_;
+}
+sub sighandler
+{
+    my $sig = shift;
+    warn "Caught $sig signal...\n";
+    debugmsg("Removing lockfile...\n");
+    unlink $lockfile;
+    # signal myself again
+    $SIG{$sig} = "DEFAULT";
+    kill $sig, $$;
+}
 sub from_cache($$$)
 {
     my( $ref, $name, $max_age) = @_;




More information about the Pkg-perl-cvs-commits mailing list