1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

wicd-curses: handle SIGQUIT signal so that we can leave the terminal in a normal state

Previously, the terminal would be left without a blinking cursor and with red text when the user pressed CTRL-\ or sent a SIGQUIT signal.
This commit is contained in:
Tom Van Braeckel
2014-12-19 15:40:39 +01:00
parent c2064b846b
commit 291f47e40d

View File

@@ -56,6 +56,9 @@ from wicd import dbusmanager
# Internal Python stuff
import sys
# SIGQUIT signal handling
import signal
# Curses UIs for other stuff
from curses_misc import ComboBox, Dialog2, NSelListBox, SelText, OptCols
from curses_misc import TextDialog, InputDialog, error, DynEdit, DynIntEdit
@@ -360,6 +363,10 @@ def gen_list_header():
return 'C %s %*s %9s %17s %6s %s' % \
('STR ', essidgap, 'ESSID', 'ENCRYPT', 'BSSID', 'MODE', 'CHNL')
""" Some people use CTRL-\ to quit the application (SIGQUIT) """
def handle_sigquit(signal_number, stack_frame):
loop.quit()
ui.stop()
########################################
##### URWID SUPPORT CLASSES
@@ -1207,6 +1214,8 @@ def main():
('red', 'dark red', 'default'),
('bold', 'white', 'black', 'bold')
])
# Handle SIGQUIT correctly (otherwise urwid leaves the terminal in a bad state)
signal.signal(signal.SIGQUIT, handle_sigquit)
# This is a wrapper around a function that calls another a function that
# is a wrapper around a infinite loop. Fun.
urwid.set_encoding('utf8')