From fde36b1271921b78b921c89887ade727e4eec784 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 29 Aug 2019 12:24:19 +1000 Subject: [PATCH] tools: tuhi-live's tuhi server needs to ignore SIGINT Handling SIGINT in the freshly-started server leads to a race condition: on Ctrl+C, Tuhi is killed before tuhi-live can call StopLive, leaving the device in live mode. On the next start of tuhi-live nothing works because the device will complain about invalid state. Simplest solution here is to ignore SIGINT in the Tuhi instance and instead rely on python's multiprocessing module to take us down when the main process exits. Fixes #206 Signed-off-by: Peter Hutterer --- tools/tuhi-live.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/tuhi-live.py b/tools/tuhi-live.py index 977c520..2989e24 100755 --- a/tools/tuhi-live.py +++ b/tools/tuhi-live.py @@ -56,6 +56,12 @@ def maybe_start_tuhi(queue): sys.path.append(os.getcwd()) import tuhi.base + import signal + + # we don't want to kill Tuhi on ctrl+c because we won't be able to reset + # live mode. Instead we rely on tuhi-live to take us down when it exits + signal.signal(signal.SIGINT, signal.SIG_IGN) + args = ['tuhi-live'] # argparse in tuhi.base.main skips argv[0] if verbose: args.append('--verbose')