From da86557b89baad5676f3867f6f2e4701b92990d7 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Tue, 20 Oct 2015 20:17:31 +0200 Subject: [PATCH] btrbk: add signal handler for SIGINT, dumping transaction log --- btrbk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/btrbk b/btrbk index dea36da..ad7975f 100755 --- a/btrbk +++ b/btrbk @@ -182,6 +182,13 @@ $SIG{__DIE__} = sub { Carp::confess @_; }; +$SIG{INT} = sub { + print STDERR "\nERROR: Cought SIGINT, dumping transaction log:\n"; + action("signal", status => "SIGINT"); + print_formatted("transaction", \@transaction_log, output_format => "tlog", outfile => *STDERR); + exit 1; +}; + sub VERSION_MESSAGE { print STDERR $version_info . "\n\n";