[tor-commits] [stem/master] When kill() fails because the process has exited, ignore the failure

atagar at torproject.org atagar at torproject.org
Wed Apr 17 18:14:45 UTC 2019


commit 1e8818e504d5a741e9e6641f77d01b1f175f8fdc
Author: teor <teor at torproject.org>
Date:   Wed Apr 17 10:53:54 2019 +1000

    When kill() fails because the process has exited, ignore the failure
---
 run_tests.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/run_tests.py b/run_tests.py
index 642644c7..8f71a20b 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -6,6 +6,7 @@
 Runs unit and integration tests. For usage information run this with '--help'.
 """
 
+import errno
 import multiprocessing
 import os
 import signal
@@ -106,8 +107,14 @@ def log_traceback(sig, frame):
   # propagate the signal to any multiprocessing children
 
   for p in multiprocessing.active_children():
-    if p.is_alive():
+    try:
       os.kill(p.pid, sig)
+    except OSError as e:
+      # If the process exited before we could kill it
+      if e.errno == errno.ESRCH: # No such process
+        pass
+      else:
+        raise e
 
   if sig == signal.SIGABRT:
     # we need to use os._exit() to abort every thread in the interpreter,



More information about the tor-commits mailing list