diff options
author | Guillaume Seren <guillaumeseren@gmail.com> | 2016-03-10 11:34:16 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2016-03-10 13:43:23 +0000 |
commit | 08ddb73351c47c053ebf983351ec235087491a25 (patch) | |
tree | 56a18b5f5f61bf21a15b7ad5fcf0c5abe9b4c873 /alot | |
parent | 2b9f3f86f230dbd61eb933199e1ea0bb30df4f11 (diff) |
Add signal for SIGINT callback ExitCommand
Diffstat (limited to 'alot')
-rw-r--r-- | alot/ui.py | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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() |