Suicide at keyboard interrupt

That's a bug, the program does not close at keyboard interruption because of threads, I pu a suicide function at the end, but suicide is never the solution.
This commit is contained in:
Sasha MOREL 2021-09-02 12:51:38 +02:00
parent 867c6daca5
commit f86fa0d6a7
1 changed files with 4 additions and 2 deletions

6
sms.py
View File

@ -8,7 +8,7 @@ from socket import AF_INET6
from threading import Thread
from time import sleep
from cgi import FieldStorage
from sys import exit
from os import kill, getpid
sms_list_program = '/data/data/com.termux/files/usr/bin/termux-sms-list'
sms_send_program = '/data/data/com.termux/files/usr/bin/termux-sms-send'
@ -357,4 +357,6 @@ if __name__ == '__main__':
except KeyboardInterrupt:
print ('Interrupt received, closing process…')
server.server_close ()
exit (0)
# BUG: the program must kill itself to end or the user must send Ctrl+C several time to close
# TODO: find another way to close the program in one action, suicide is never the solution
kill (getpid (), 15)