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:
parent
caef9a72fc
commit
83e8fca2e0
@ -7,6 +7,9 @@ ChangeLog
|
|||||||
WIP (add new stuff for the next release)
|
WIP (add new stuff for the next release)
|
||||||
========================================
|
========================================
|
||||||
|
|
||||||
|
=======
|
||||||
|
* SIGHUP is now handled as the termination notification rather than
|
||||||
|
the signal to reread the configuration (Dmitrijs Ledkovs)
|
||||||
* Honor the timezone of emails (Tobias Thierer)
|
* Honor the timezone of emails (Tobias Thierer)
|
||||||
|
|
||||||
OfflineIMAP v6.5.5-rc1 (2012-09-05)
|
OfflineIMAP v6.5.5-rc1 (2012-09-05)
|
||||||
|
@ -308,7 +308,8 @@ SAFE CONNECTION GUARANTEEING THE AUTHENTICITY OF YOUR IMAP SERVER!
|
|||||||
UNIX Signals
|
UNIX Signals
|
||||||
============
|
============
|
||||||
|
|
||||||
OfflineImap listens to the unix signals SIGUSR1 and SIGUSR2.
|
OfflineImap listens to the unix signals SIGUSR1, SIGUSR2, SIGTERM,
|
||||||
|
SIGINT, SIGHUP:
|
||||||
|
|
||||||
If sent a SIGUSR1 it will abort any current (or next future) sleep of all
|
If sent a SIGUSR1 it will abort any current (or next future) sleep of all
|
||||||
accounts that are configured to "autorefresh". In effect, this will trigger a
|
accounts that are configured to "autorefresh". In effect, this will trigger a
|
||||||
@ -319,6 +320,12 @@ accounts will abort any current sleep and will exit after a currently running
|
|||||||
synchronization has finished. This signal can be used to gracefully exit out of
|
synchronization has finished. This signal can be used to gracefully exit out of
|
||||||
a running offlineimap "daemon".
|
a running offlineimap "daemon".
|
||||||
|
|
||||||
|
SIGTERM, SIGINT, SIGHUP are all treated to gracefully terminate as
|
||||||
|
soon as possible. This means it will finish syncing the current folder
|
||||||
|
in each account, close keep alive connections, remove locks on the
|
||||||
|
accounts and exit. It may take up to 10 seconds, if autorefresh option
|
||||||
|
is used.
|
||||||
|
|
||||||
Folder filtering and nametrans
|
Folder filtering and nametrans
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
@ -329,14 +329,14 @@ class OfflineImap:
|
|||||||
syncaccounts.append(account)
|
syncaccounts.append(account)
|
||||||
|
|
||||||
def sig_handler(sig, frame):
|
def sig_handler(sig, frame):
|
||||||
if sig == signal.SIGUSR1 or sig == signal.SIGHUP:
|
if sig == signal.SIGUSR1:
|
||||||
# tell each account to stop sleeping
|
# tell each account to stop sleeping
|
||||||
accounts.Account.set_abort_event(self.config, 1)
|
accounts.Account.set_abort_event(self.config, 1)
|
||||||
elif sig == signal.SIGUSR2:
|
elif sig == signal.SIGUSR2:
|
||||||
# tell each account to stop looping
|
# tell each account to stop looping
|
||||||
getglobalui().warn("Terminating after this sync...")
|
getglobalui().warn("Terminating after this sync...")
|
||||||
accounts.Account.set_abort_event(self.config, 2)
|
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)
|
# tell each account to ABORT ASAP (ctrl-c)
|
||||||
getglobalui().warn("Terminating NOW (this may "\
|
getglobalui().warn("Terminating NOW (this may "\
|
||||||
"take a few seconds)...")
|
"take a few seconds)...")
|
||||||
|
Loading…
Reference in New Issue
Block a user