Make SIGHUP singal handler equivalent to SIGTERM and SIGINT.
offlineimap has several frontends that encourage running it from a terminal under an X session. When X session closes for a system shutdown, the terminals exit, after sending SIGHUP to their children. Previously SIGHUP was treated to be equivalent to SIGUSR1, i.e. wake up and sync all accounts. This causes delays during shutdown. According to Wikipedia [0], SIGHUP has been repurposed from a historical meaning to one of: * re-read configuration files, or reinitialize (e.g. Apache, sendmail) * controlling pseudo or virtual terminal has been closed I believe second meaning is more appropriate for offlineimap, and hence this patch makes SIGHUP to be handled in the same way SIGTERM and SIGINT are handled. [0] http://en.wikipedia.org/wiki/SIGHUP Debian-Bug: http://bugs.debian.org/670120 Reported-By: Steve Langasek <steve.langasek@canonical.com> Signed-off-by: Dmitrijs Ledkovs <xnox@debian.org> Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:

committed by
Eygene Ryabinkin

parent
caef9a72fc
commit
83e8fca2e0
@ -329,14 +329,14 @@ class OfflineImap:
|
||||
syncaccounts.append(account)
|
||||
|
||||
def sig_handler(sig, frame):
|
||||
if sig == signal.SIGUSR1 or sig == signal.SIGHUP:
|
||||
if sig == signal.SIGUSR1:
|
||||
# tell each account to stop sleeping
|
||||
accounts.Account.set_abort_event(self.config, 1)
|
||||
elif sig == signal.SIGUSR2:
|
||||
# tell each account to stop looping
|
||||
getglobalui().warn("Terminating after this sync...")
|
||||
accounts.Account.set_abort_event(self.config, 2)
|
||||
elif sig == signal.SIGTERM or sig == signal.SIGINT:
|
||||
elif sig in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP):
|
||||
# tell each account to ABORT ASAP (ctrl-c)
|
||||
getglobalui().warn("Terminating NOW (this may "\
|
||||
"take a few seconds)...")
|
||||
|
Reference in New Issue
Block a user