From f86fa0d6a7713a090d238df79c2b6146ddda0bbd Mon Sep 17 00:00:00 2001 From: Sasha MOREL Date: Thu, 2 Sep 2021 12:51:38 +0200 Subject: [PATCH] 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. --- sms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sms.py b/sms.py index 009cfc5..dfcb50c 100755 --- a/sms.py +++ b/sms.py @@ -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) \ No newline at end of file + # 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) \ No newline at end of file