summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorGuillaume Seren <guillaumeseren@gmail.com>2016-03-10 11:34:16 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2016-03-10 13:43:23 +0000
commit08ddb73351c47c053ebf983351ec235087491a25 (patch)
tree56a18b5f5f61bf21a15b7ad5fcf0c5abe9b4c873 /alot
parent2b9f3f86f230dbd61eb933199e1ea0bb30df4f11 (diff)
Add signal for SIGINT callback ExitCommand
Diffstat (limited to 'alot')
-rw-r--r--alot/ui.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 8dff2839..2f46aa8a 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -8,6 +8,7 @@ from twisted.internet import reactor, defer
from settings import settings
from buffers import BufferlistBuffer
+from commands import globals
from commands import commandfactory
from commands import CommandCanceled
from alot.commands import CommandParseError
@@ -69,6 +70,7 @@ class UI(object):
mainframe = urwid.Frame(urwid.SolidFill())
self.root_widget = urwid.AttrMap(mainframe, global_att)
+ signal.signal(signal.SIGINT, self.handle_signal)
signal.signal(signal.SIGUSR1, self.handle_signal)
# set up main loop
@@ -650,6 +652,10 @@ class UI(object):
:param signum: The signal number (see man 7 signal)
:param frame: The execution frame (https://docs.python.org/2/reference/datamodel.html#frame-objects)
"""
+ # it is a SIGINT ?
+ if signum == signal.SIGINT:
+ logging.info('shut down cleanly')
+ self.apply_command(globals.ExitCommand())
self.current_buffer.rebuild()
self.update()