Abort transaction on SIGINT
This commit is contained in:
parent
5d37f7af5b
commit
9f905b84d5
2 changed files with 15 additions and 1 deletions
|
@ -2,4 +2,11 @@
|
||||||
|
|
||||||
sub command { NEXT }
|
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.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
7
revbank
7
revbank
|
@ -67,6 +67,13 @@ sub prompt {
|
||||||
|
|
||||||
my $begin = my $time = time;
|
my $begin = my $time = time;
|
||||||
while (not $done) {
|
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)) {
|
if ($select->can_read(.05)) {
|
||||||
$readline->callback_read_char;
|
$readline->callback_read_char;
|
||||||
$begin = $time;
|
$begin = $time;
|
||||||
|
|
Loading…
Add table
Reference in a new issue