tools/difF_test_tp handle CTRL-C and kill everything immediately

We don't care about graceful termination of subprocesses as
the diff tests are stateless. All their state is in-memory and
boils down to a PASS/FAIL stdout.
Just broadcast a SIGKILL when ctrl-c is pressed.

Change-Id: Ibfb0468ac5f6c7c0f64d544b099e0bca7e6c7046
diff --git a/tools/diff_test_trace_processor.py b/tools/diff_test_trace_processor.py
index 4902b2f..41166fc 100755
--- a/tools/diff_test_trace_processor.py
+++ b/tools/diff_test_trace_processor.py
@@ -24,6 +24,7 @@
 import json
 import os
 import re
+import signal
 import subprocess
 import sys
 import tempfile
@@ -392,7 +393,18 @@
   return tests
 
 
+def ctrl_c_handler(_num, _frame):
+  # Send a sigkill to the whole process group. Our process group looks like:
+  # - Main python interpreter running the main()
+  #   - N python interpreters coming from ProcessPoolExecutor workers.
+  #     - 1 trace_processor_shell subprocess coming from the subprocess.Popen().
+  # We don't need any graceful termination as the diff tests are stateless and
+  # don't write any file. Just kill them all immediately.
+  os.killpg(os.getpid(), signal.SIGKILL)
+
+
 def main():
+  signal.signal(signal.SIGINT, ctrl_c_handler)
   parser = argparse.ArgumentParser()
   parser.add_argument('--test-type', type=str, default='all')
   parser.add_argument('--trace-descriptor', type=str)