[tracker/sam/sandbox-improvements: 4/4] trackertestutils: Fix crash on SIGINT



commit 4c3c72a2c73a21c5f5bb2dbe6fb9677521af6ce0
Author: Sam Thursfield <sam afuera me uk>
Date:   Sun Mar 8 22:17:29 2020 +0100

    trackertestutils: Fix crash on SIGINT
    
    This code never executed because the sandbox would probably
    have already crashed due to the D-Bus daemon exiting before
    we wanted it to.

 utils/trackertestutils/__main__.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/utils/trackertestutils/__main__.py b/utils/trackertestutils/__main__.py
index 63c594801..e7b10e8ed 100644
--- a/utils/trackertestutils/__main__.py
+++ b/utils/trackertestutils/__main__.py
@@ -408,13 +408,21 @@ def main():
             command = [shell, '-c', ' '.join(shlex.quote(c) for c in args.command)]
 
             log.debug("Running: %s", command)
-            result = subprocess.run(command)
+            interrupted = False
+            try:
+                result = subprocess.run(command)
+            except KeyboardInterrupt:
+                interrupted = True
 
             if len(miner_watches) > 0:
                 wait_for_miners(miner_watches)
 
-            log.debug("Process finished with returncode %i", result.returncode)
-            sys.exit(result.returncode)
+            if interrupted:
+                log.debug("Process exited due to SIGINT")
+                sys.exit(0)
+            else:
+                log.debug("Process finished with returncode %i", result.returncode)
+                sys.exit(result.returncode)
     finally:
         sandbox.stop()
         if index_tmpdir:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]