diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2009-10-21 10:26:17 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2009-10-21 10:26:17 +0000 |
commit | 7862967e1ca8356a5be56376492ca8c6e6a00452 (patch) | |
tree | 824ad525bec89d48a2475b311c135ce96d8ec0ca | |
parent | fd6b415be74eb37d5611c85e9bc6a7af36d6134d (diff) |
catch signals when we start doing stuff... so that cleaning up at the
end always occur, unless you insist on ^C.
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index d4e784c85ac..646eaf71e0e 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.364 2009/10/21 10:22:58 espie Exp $ +# $OpenBSD: pkg_add,v 1.365 2009/10/21 10:26:16 espie Exp $ # # Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # @@ -781,6 +781,12 @@ if ($bad) { } +my $handler = sub { my $sig = shift; die "Caught SIG$sig"; }; +local $SIG{'INT'} = $handler; +local $SIG{'QUIT'} = $handler; +local $SIG{'HUP'} = $handler; +local $SIG{'KILL'} = $handler; +local $SIG{'TERM'} = $handler; # This is the actual very small loop that adds all packages eval { |