Abort after three Ctrl-C keystrokes

By default, OfflineIMAP catches SIGTERM/SIGHUP/SIGINT and attempts to
gracefully terminate as soon as possible. Allow the user to abort
immediately, by hitting Ctrl-C several times.

Bug-Debian: https://bugs.debian.org/679975
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Ilias Tsitsimpis 2016-02-04 12:31:29 +02:00 committed by Nicolas Sebrecht
parent 3174ea0bd3
commit 37bcd45e4e

View File

@ -362,10 +362,17 @@ class OfflineImap:
accounts.Account.set_abort_event(self.config, 3)
if 'thread' in self.ui.debuglist:
self.__dumpstacks(5)
# Abort after three Ctrl-C keystrokes
self.num_sigterm += 1
if self.num_sigterm >= 3:
getglobalui().warn("Signaled thrice. Aborting!")
sys.exit(1)
elif sig == signal.SIGQUIT:
stacktrace.dump(sys.stderr)
os.abort()
self.num_sigterm = 0
signal.signal(signal.SIGHUP, sig_handler)
signal.signal(signal.SIGUSR1, sig_handler)
signal.signal(signal.SIGUSR2, sig_handler)