From ed9540b4a92d2abb6719d36418f3827ac313a59d Mon Sep 17 00:00:00 2001 From: Gaurav Sinha Date: Sat, 17 Nov 2012 00:57:57 -0800 Subject: Add signal handler to handle CTRL+C to avoid commit blockade on lock file (cherry picked from commit 69de682b364d7bce7aefecb00a4e06eceaeb834d) --- lib/Vyatta/IpTables/IpSet.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm index 5c4b6ce..729c58e 100755 --- a/lib/Vyatta/IpTables/IpSet.pm +++ b/lib/Vyatta/IpTables/IpSet.pm @@ -55,6 +55,15 @@ my $logger = 'logger -t IpSet.pm -p local0.warn --'; my $addr_range_mask = 24; my $lockfile = "/opt/vyatta/config/.lock"; +# remove lock file to avoid commit blockade on interrupt +# like CTRL+C. +sub INT_handler { + my $rc = system("sudo rm -f $lockfile >>/dev/null"); + exit(0); +} + +$SIG{'INT'} = 'INT_handler'; + sub new { my ($that, $name, $type) = @_; -- cgit v1.2.3