[llvm-branch-commits] [llvm] 719a040 - [lit] Stop holding subprocess objects open in TimeoutHelper (#186712)

Cullen Rhodes via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 30 08:07:24 PDT 2026


Author: Nick Begg
Date: 2026-03-30T15:07:15Z
New Revision: 719a040bf13fc854bde9e35a95520a78cf021c37

URL: https://github.com/llvm/llvm-project/commit/719a040bf13fc854bde9e35a95520a78cf021c37
DIFF: https://github.com/llvm/llvm-project/commit/719a040bf13fc854bde9e35a95520a78cf021c37.diff

LOG: [lit] Stop holding subprocess objects open in TimeoutHelper (#186712)

Tweak TestRunner's TimeoutHelper storage to hold only PIDs rather
than the whole process object. Holding the object causes many pipes to
stay open, when all we need is the pid.

Addresses #185941

(cherry picked from commit 202ef22faeb1c2a7b5846a446e8c8dfe579d7c29)

Added: 
    

Modified: 
    llvm/utils/lit/lit/TestRunner.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index e9d73ade9827e..0d151ff96583e 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -136,7 +136,9 @@ def addProcess(self, proc):
             return
         needToRunKill = False
         with self._lock:
-            self._procs.append(proc)
+            # just store the pid, rather than the whole proc object.
+            # Holding the proc object keeps resources (eg pipes) open unnecessarily.
+            self._procs.append(proc.pid)
             # Avoid re-entering the lock by finding out if kill needs to be run
             # again here but call it if necessary once we have left the lock.
             # We could use a reentrant lock here instead but this code seems
@@ -176,8 +178,8 @@ def _kill(self):
         the initial call to _kill()
         """
         with self._lock:
-            for p in self._procs:
-                lit.util.killProcessAndChildren(p.pid)
+            for pid in self._procs:
+                lit.util.killProcessAndChildren(pid)
             # Empty the list and note that we've done a pass over the list
             self._procs = []  # Python2 doesn't have list.clear()
             self._doneKillPass = True


        


More information about the llvm-branch-commits mailing list