Abort transaction on SIGINT

This commit is contained in:
Juerd Waalboer 2019-07-02 04:38:21 +02:00
parent 5d37f7af5b
commit 9f905b84d5
2 changed files with 15 additions and 1 deletions

View file

@ -2,4 +2,11 @@
sub command { NEXT }
$SIG{INT} = 'IGNORE';
$SIG{INT} = sub {
$::ABORT_HACK = "^C";
# DO NOT USE this global variable. It's a nasty hack. In most cases,
# you should "return ABORT" instead, or maybe "main::abort()" when doing
# nastier stuff. You should only need $::ABORT_HACK in signal handlers.
};

View file

@ -67,6 +67,13 @@ sub prompt {
my $begin = my $time = time;
while (not $done) {
if ($::ABORT_HACK) {
# Global variable that a signal handling plugin can set.
# Do not use, but "return ABORT" instead.
my $reason = $::ABORT_HACK;
$::ABORT_HACK = 0;
abort($reason);
}
if ($select->can_read(.05)) {
$readline->callback_read_char;
$begin = $time;