Move signal code into gajim.py
The reason for signal.signal(signal.SIGPIPE, signal.SIG_DFL) Python ignores SIGPIPE by default ( signal(SIGPIPE, SIG_IGN) ) Write on a socket return then an error 32 EPIPE, which naturally turns into an exception. signal.SIG_DFL restores normal UNIX behavior
This commit is contained in:
parent
72df2524e9
commit
4731e8491b
|
@ -55,10 +55,6 @@ except Exception:
|
||||||
randomsource = random.Random()
|
randomsource = random.Random()
|
||||||
randomsource.seed()
|
randomsource.seed()
|
||||||
|
|
||||||
import signal
|
|
||||||
if os.name != 'nt':
|
|
||||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import certifi
|
import certifi
|
||||||
import OpenSSL.crypto
|
import OpenSSL.crypto
|
||||||
|
|
|
@ -78,7 +78,7 @@ def _init_gtk():
|
||||||
from gajim.application import GajimApplication
|
from gajim.application import GajimApplication
|
||||||
|
|
||||||
application = GajimApplication()
|
application = GajimApplication()
|
||||||
_install_terminate(application)
|
_install_sginal_handlers(application)
|
||||||
application.run(sys.argv)
|
application.run(sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,13 +100,15 @@ def _set_proc_title():
|
||||||
libc.setproctitle('gajim')
|
libc.setproctitle('gajim')
|
||||||
|
|
||||||
|
|
||||||
def _install_terminate(application):
|
def _install_sginal_handlers(application):
|
||||||
def sigint_cb(num, stack):
|
def sigint_cb(num, stack):
|
||||||
print('SIGINT/SIGTERM received')
|
print('SIGINT/SIGTERM received')
|
||||||
application.quit()
|
application.quit()
|
||||||
# ^C exits the application normally
|
# ^C exits the application normally
|
||||||
signal.signal(signal.SIGINT, sigint_cb)
|
signal.signal(signal.SIGINT, sigint_cb)
|
||||||
signal.signal(signal.SIGTERM, sigint_cb)
|
signal.signal(signal.SIGTERM, sigint_cb)
|
||||||
|
if os.name != 'nt':
|
||||||
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in New Issue