[lldb/Test] Don't leak forked processes on Darwin
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 29 May 2020 20:56:44 +0000 (13:56 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 29 May 2020 20:58:12 +0000 (13:58 -0700)
We are leaking forked processes on macOS because the cleanup function
was checking the existence of /proc/pid which does not exist on macOS.
I've changed the code to be platform agnostic.

lldb/packages/Python/lldbsuite/test/lldbtest.py

index 0dee4f2..04ba7ea 100644 (file)
@@ -884,8 +884,10 @@ class Base(unittest2.TestCase):
         del self.subprocesses[:]
         # Ensure any forked processes are cleaned up
         for pid in self.forkedProcessPids:
-            if os.path.exists("/proc/" + str(pid)):
+            try:
                 os.kill(pid, signal.SIGTERM)
+            except OSError:
+                pass
 
     def spawnSubprocess(self, executable, args=[], install_remote=True):
         """ Creates a subprocess.Popen object with the specified executable and arguments,