diff options
author | morpheus65535 <[email protected]> | 2024-01-10 23:04:23 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-10 23:04:23 -0500 |
commit | 0807bd99b956ee3abf18acc3bec43a87fc8b1530 (patch) | |
tree | a570c745999b588c5c21ef79cd1f4f6f2058cf61 /bazarr.py | |
parent | c17d127323cd4c62a075e3c6d26719b700e73d5a (diff) | |
download | bazarr-0807bd99b956ee3abf18acc3bec43a87fc8b1530.tar.gz bazarr-0807bd99b956ee3abf18acc3bec43a87fc8b1530.zip |
Fixed improper closing of resources on exit
Diffstat (limited to 'bazarr.py')
-rw-r--r-- | bazarr.py | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -52,22 +52,27 @@ dir_name = os.path.dirname(__file__) def end_child_process(ep): try: - ep.kill() + if os.name != 'nt': + try: + ep.send_signal(signal.SIGINT) + except ProcessLookupError: + pass + else: + import win32api + import win32con + try: + win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, ep.pid) + except KeyboardInterrupt: + pass except: - pass - -def terminate_child_process(ep): - try: ep.terminate() - except: - pass def start_bazarr(): script = [get_python_path(), "-u", os.path.normcase(os.path.join(dir_name, 'bazarr', 'main.py'))] + sys.argv[1:] ep = subprocess.Popen(script, stdout=None, stderr=None, stdin=subprocess.DEVNULL) atexit.register(end_child_process, ep=ep) - signal.signal(signal.SIGTERM, lambda signal_no, frame: terminate_child_process(ep)) + signal.signal(signal.SIGTERM, lambda signal_no, frame: end_child_process(ep)) def check_status(): |