capture ctrl c signal properly and shutdown nicely

This commit is contained in:
chrys87 2016-07-08 09:49:59 +02:00 committed by GitHub
parent 75a9a7fcdf
commit e2fb6de631

View File

@ -3,7 +3,7 @@
# Fenrir TTY screen reader # Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributers.
import os, sys, time import os, sys, time, signal
DEBUG = False DEBUG = False
@ -32,6 +32,7 @@ class fenrir():
self.bindings = {} self.bindings = {}
self.autospeak = [] self.autospeak = []
self.soundIcons = {} self.soundIcons = {}
signal.signal(signal.SIGINT, self.captureSignal)
# the following hard coded, in future we have a config loader # the following hard coded, in future we have a config loader
self.runtime['speechDriverString'] = 'speechd' self.runtime['speechDriverString'] = 'speechd'
@ -63,8 +64,14 @@ class fenrir():
self.runtime = self.runtime # command queue here self.runtime = self.runtime # command queue here
def shutdown(self): def shutdown(self):
self.threadUpdateScreen.stop() self.runtime['running'] = False
self.threadHandleInput.stop() if self.runtime['speechDriver'] != None:
self.runtime['speechDriver'].shutdown()
if self.runtime['debug'] != None:
self.runtime['debug'].closeDebugFile()
def captureSignal(self, siginit, frame):
self.shutdown()
app = fenrir() app = fenrir()
app.proceed() app.proceed()